2010/3/18 Rémi Forax <[email protected]> > Le 18/03/2010 00:59, Paulo Levi a écrit : > > My understanding is that set implementations are implemented by using Maps >> internally + a marker object, and that since Maps are implemented using >> arrays of entries this is at least n*3 references more that what is needed, >> since there are never multiple values. >> >> Any plans to change this? I suspect it would be a boon for programs that >> use the correct data structure. >> >> > You have to test it. > My guess is that there will be no difference. > As far as I remember, an object needs to be aligned on a valid 64bits > address even in 32bits mode, > Hotspot uses a 64bits header and the internal hash map entry contains 4 > ints, > if you remove the reference corresponding to the value, the empty place > will be > considered as garbage and not used. >
> Else, you can try to remove the internal entry object but in that case > the hashcode of the element will be not stored anymore and you will > have a slowdown for all objects that doesn't cache their hashcode by > itself. > > Rémi > > See my second-to-last post in this thread: http://groups.google.com/group/guava-discuss/browse_thread/thread/23bc8fa5ae479698 In short, I tested removing the "value" field of a HashMap's entry object, and indeed (through Instrumentation#getObjectSize) I observed no reduction in memory. I had to remove one further field (e.g. "hash") to make a reduction (of 8 bytes per entry). Dimitris
