Garbage Collector glitches

I looked at my code, no repeated memory allocation, but I continue to have little ciclic garbage lag.

There is a technic for remove those little glitches ???

Did you profile your code to try to see where Objects are being created? Maybe methods you are calling are creating garbage.

http://www.hp.com/products1/unix/java/hpjmeter/ can help and is free but there is better if you can drop some cash.

The alternative is to try calling System.gc() semi-often but there are lots of reason that isn’t a reliable solution if it does seem to work for you.

“String operations” + “especially concatination” + “can create lots of garbage, all without the presence of the telltale new operator…”

GC glitches are also the reason why the LinkedList is almost totally unusable - an iterator created every time I want to loop though? No thanks.

I still couldn’t get rid of some teeny GC glitches in XAP despite getting my new()ing down to just allocating new gidrahs when they spawned. Solved it with -Xincgc -Xconcgc.

You have to create some garbage here and there.

I advise a System.gc() when a level ends too :smiley:

Cas :slight_smile:

it’s ammazing, those options removed it …

thx ;D

Without being able to track that down, we found the GC is not the main reason for ‘glitches’. In our gaming app, when prototyping things, 1000ths of objects may be allocated per second. After removing the ‘news’ and replacing them with object-reuse (most they are Matrix4f/Vector3f), there was no significant improvement.
I used to log the GC by -verboce:gc and found there was no coinicidence of GC events and the perceivable glitches - even if we run with 100fps and above.

GC maybe one source, but on todays very fast machines, it is also a very fast thing and seldom the reason, although often suspected.

So basically what should I avoid to do after System.gc() ? Create all objects of course, and then? Shouldn´t I do string operations in performance critical situations?

More specifically, you should use String operations as little as possible and create as little as possible (short lived) objects (especially heavy ones) in general in your game loops and inner loops.
Certainly, avoiding the new keyword doesn’t necessarily mean that you’re not creating garbage.
Just do one XSL transformation using Xalan in your game loop and you’ll know what I mean ;D (no GC can cope with that)

So you mean that I should remove the method that reads my 20 XML files every frame? =P

;D