IdentityHashMap & natStackTrace

Rutger Ovidius r_ovidius@eml.cc
Thu Nov 25 20:04:00 GMT 2004


Hi,

I'm using gcc version 4.0.0 20041113 (experimental).

In StackTrace.java/natStackTrace.cc(update()) an IdentityHashMap is
used to store all methods.

IdentityHashMap.java:

emptyslot = new Object();

public Object put(Object key, Object value)
       ...
       if (size > threshold) {
          table = new Object[old.length << 1 + 2];
          Arrays.fill(table, emptyslot);
       ...
       }
       ...
       
I suppose I have a lot of classes/methods in my app, and once it
crosses a certain threshold, this map ballons from 21,504 to 172,032
entries in one expansion. This seems excessive. Sun's java simply
doubles the size AFAIK.

This implementation fills the array with emptyslot (Arrays.fill),
which uses a whole bunch of memory. Can't a guard be used on lookups
instead of actually filling this in (checking equality with
emptyslot)?

These two issues seem to be a burden on the heap.  I can drop ~400k of
ram by doubling the size of this instead of using "old.length << 1 +
2" during each table expansion.

Regards,
Rutger Ovidius





More information about the Java mailing list