I've written a JAva program that uses JNI to call some C++ methods to retrieve webcam images using video for windows. The problem is that every time I retrieve an image, memory usage keeps going up. I'm still a noob to C++ so the problem may be something really simple. Here's my code:

One thing I notice is that you are using the wrong form of delete. Since you used new[] to allocate space for the BYTE array, you should use delete [] frame to delete it. (There is a missing semi-colon there in your code, how does that even compile?)

You could also just use a vector<BYTE> so you don't have to worry about managing the memory.