Memory leak using bufferStrategy

Hello ~
I am writing a 2d engine which is currently supposed to run in an applet on a Canvas.
I m using bufferStrategy and every time I call myBufferStrategy.show() I get 4 kb of memory eaten up by the jvm… I know it’s caused by this… because I commented that line… and the memory leaking stops…
Any ideas?

Do you call dispose() on the Graphics object obtained from getDrawGraphics() ?

Yep

How come you are so sure it’s a leak?

The garbage-collector tends to have it’s own ideas about when to clean up objects.

Try System.gc() each frame, and see if the space gets reclaimed, eventually.

I’d be surprised if we had a 4kb leak per buffer swap. Given that you typically have 60 frames
per second, we’d be running out of memory pretty quickly.

How did you determined the size of the leak? (what tool did you use?)

What’s your jre version? Video board? OS?

Can you reproduce it in mustang (jdk6.0)?

Thanks,
Dmitri
Java2D Team

Basically… it eats up 4 kb/sec at a very steady rate without stopping or going down (would expect that to happen when the garbage collector gets to work…). I m just using the windows task manager to see it… it’s pretty clear. I m running jdk 1.4.2_10 for compatibility with mac os atm, win xp sp2, graphics card/ processor don’t matter, it does so on 3 different systems.
I think it must be my mistake… it can’t just be the bufferStrategy, going to review all the code and see if I don’t call .dispose() on something… will let you know if this gets fixed, thanks for your time ~

-Regards

Ok… I need to stop coding at 5 am…
Here’s the catch…
A method called for rendering was instancing a Graphics object and not calling dispose()… obviously =D
I was so sure it was the .show() method at the beginning… because commenting the call to that also stops the call to this method… but looking more closely… I finally found out I need to sleep more…
Thanks all again for your help ~

-Regards, a random sleepy head ~