[Winpcap-users] How to tell if memory is being freed properly?

Guy Harris guy at alum.mit.edu
Wed Jan 6 17:09:09 PST 2010

On Jan 6, 2010, at 4:50 PM, Angelina Viola wrote:

> Hello all, I am using WinPcap to test out some raw packet injection for a project that uses a custom protocol. I started from the code here:
> http://www.codeproject.com/KB/IP/UDPandWPCAP.aspx
> However, I am currently searching for memory leaks

Unless the code in that project calls pcap_freealldevs() on the list it gets back from pcap_findalldevs_ex(), that's a leak.  Presumably, if you're using that code, it's only calling pcap_findalldevs_ex() once, so it's not a *continuing* leak, however.

> and I noticed that when I looked at my app in task manager it was increasing its memory usage like crazy. I wanted to see what was causing the memory usage, and my first notion was that packets weren't getting freed somewhere. So I swapped out my packet_handler() function for the example one which comes in basic_dump.c, and switched my libraries to 4.1.1.
> It still seems that memory just keeps going up and up. I know that I'm not supposed to free the pkt_data pointer myself, so is there some config I should know about or something so that WinPcap doesn't just keep increasing in size?

How do you know that it's WinPcap, not your application?  WinPcap isn't supposed to keep allocating memory while you're capturing traffic, no matter *how* it's configured.

Could you send us your code, so we can see whether there's a leak in it?

More information about the Winpcap-users mailing list