Hi Mark,
hope you had a nice time on your holiday!
Just wondering if the memory leak fixed in the v1.2 code was back ported to v1.1
I took a look at the v1.1 pcap_callback and it still seems to be missing the following line:
env->DeleteLocalRef(buffer);
I think this is the fix. Can I just add it to the v1.1 code if it is?
Ta,
Scott
Well, had a little fun getting this built on Windows (I'm a *nix kinda guy). Thought I'd share what was required in case anyone is interested.
Download and install JDK e.g. C:\Java\jdk1.6.0_10
Download ANT (http://ant.apache.org/)
Extract ANT to somewhere e.g. c:\ant
Add c:\ant\bin to PATH
Add the following environment variables
ANT_HOME=c:\ant
JAVA_HOME=C:\Java\jdk1.6.0_10
Download cpptasks (http://ant-contrib.sourceforge.net/cpptasks/index.html)
extract cpptasks e.g. C:\work\dev\cpptasks-1.0b5
Build it as follows:
> cd C:\work\dev\cpptasks-1.0b5
> ant
copy the C:\work\dev\cpptasks-1.0b5\target\lib\cpptasks.jar to c:\ant\lib
Download jdeb (http://vafer.org/projects/jdeb/)
extract jdeb.jar to c:\ant\lib
install jnetpcap source e.g. C:\work\dev\jnetpcap-1.1-win32
make the following directories for the additional packages required
> mkdir C:\work\dev\jnetpcap-1.1-win32\lib
> mkdir C:\work\dev\jnetpcap-1.1-win32\lib\WpdPack_4_0_1
> mkdir C:\work\dev\jnetpcap-1.1-win32\lib\junit4.5
Download development version of WinPcap (http://www.winpcap.org/devel.htm)
extract the WpdPack folder to C:\work\dev\jnetpcap-1.1-win32\lib\WpdPack_4_0_1\WpdPack
Download junit4.5.jar (http://www.junit.org/) to C:\work\dev\jnetpcap-1.1-win32\lib\junit4.5
Update the junit version in the C:\work\dev\jnetpcap-1.1-win32\lib.properties file
Download the following MinGW packages (http://www.mingw.org/)
- mingw-runtime
- w32api
- binutils
- gcc-core
- gcc-g++
Extract all the above e.g. c:\mingw
Add the c:\mingw\bin to your path
Modify the 'win' variable in C:\work\dev\jnetpcap-1.1-win32\tests\java\org\jnetpcap to a valid device on your machine
Build jnetpcap
> cd C:\work\dev\jnetpcap-1.1-win32
> ant
Yes that is the fix.
Easy work around is to not loop forever using Pcap.loop but put it in an infinite while-loop and do Pcap.loop for a certain amount of packets.
What happens is that in the loop the JNI LocalReferences are being released, but only when the Pcap.loop exits. If you put it infinitely they LocalReferences (and thus the ByteBuffers as well) just accumulate eventually you run out of memory.
So:
while(true) {
Pcap.loop(1000, .....);
}
should do the trick. The official fix is in 1.2.
Pcap.dispatch is not effected the same way as it doesn't loop forever and eventually has a chance to release the LocalReferences.
PS: vacation was amazing
Got a good suntan and even cooked a little too much. Then we came home today to Syracuse NY and the temp was 32deg-F 
Thanks for the post deaks 
Just wanted to add that cpptasks, junit and WinPcap zip are all in the lib/ directory of the SVN jNetPcap repository for convenience. They are not the latest, though, so if everyone requires to compile against the latest then should follow deaks' advice.
To get the exact source for each release you need to use the SVN directory on sf.net SVN server jNetPcap/releases/<latest available>.
jNetPcap/trunk of course is the current under development stuff that will eventually end up in the next release.
Doh, I completely forgot about checking for previous revisions in SVN.... That is so much easier than what I did! 
Many thanks,
Scott