Garbage Collection in an Applet

Hello,

I am working on an applet that relies heavily on animation, and when 1.5 came out most of my problems have been solved(hi res timer!). Now I am noticing that the GC seems to be running about once every 6 seconds, causing a noticable stutter on a very regular basis.

I have never had to worry about this before, and was wondering what I can do through an applet about the GC. I know that you can set all sorts of options through command lines, but what about applets? Most of my garbage is being created by the awt mouse events, which I can’t really stop from happening.

I am using java2D, and not using any swing components at all.

Any suggestions?

MouseEvents are teeny tiny things and it would take a very, very long time to fill up the heap with them. Time to profile your applet and see what’s really going on.

Cas :slight_smile:

I suggest to cap your fps. About ~60 is really enough for a 2d game. That leaves some air for gc.

Disable debug outputs in the console, if you put there any.

[quote]MouseEvents are teeny tiny things and it would take a very, very long time to fill up the heap with them.[…]
[/quote]
200hz -> up to 200 events per second… circling 10 seconds and you have 2000 objects of pure garbage, but they won’t last that long and shouldn’t be a problem anyways :wink: