« Business Rules != Scripting | Main | Programmeurs Sans Responsabilité »

java.util.ThrashMap

Listen to this articleListen to this article

I received a very interesting post from the JESS mailing list last night and thought it was worth a mention.

There's a weird threshold that can occur with any Java data structure that uses large arrays of Object references (Object[]). If the size of the Object array exceeds the maximum size of objects that can be placed in the "new generation", garbage collection performance can be severely impacted...

I'm not sure if I'm likely to see this problem really but I do ue HashMaps a fair bit so I thought it was interesting. In general I don't find the need to use arrays much if at all these days. In fact, for some inexplicable reason, I tend to use LinkedList over ArrayList and, except for Simian which uses lovingly hand-crufted data structures, I can't recall ever holding maps of data large enough to exhibit this behaviour. But then again I'm not implementing a Rules Engine.

TrackBack

Listed below are links to weblogs that reference java.util.ThrashMap:

» Pathological Behavior in Sun's Generational Garbage Collector from Creative Karma
Simon Harris points to a posting about a HashMap performance problem: There's a weird threshold that can occur with any Java data structure that uses large arrays of Object references (Object[]). [Read More]

Comments

> In fact, for some inexplicable reason, I tend to use LinkedList over ArrayList

could it be that you add, remove and iterate more often than you index?

Most probably. Who knows but the aversion is there. Come to think of it, I don't really use Lists all that much either, tending to use Maps and Sets much more often.

Post a comment