[gclist] Java vs. ML, particularly GC

Pekka P. Pirinen pekka@harlequin.co.uk
Wed, 3 Jan 2001 19:29:16 GMT


> My question is how can you deduce the object overhead from doing
> experiments with the JVM.

You probably can't deduce it exactly, as there could be some off-line
tables that get allocated in large steps (page tables, mark bits,
etc.).  However, such things contribute a small fraction of the
overhead, and are probably not even counted by the interfaces provided
to ask about memory consumption.  The best way might be to ask your
JVM vendor.

> While i agree with Eliot's model of 2 words
> of overhead for Objects and 3 words for Object[]'s for JDK 1.3., on NT
> my estimates are different.

2/3 words is reasonable, but implementors often find other
considerations more pressing and increase the overhead.

> Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
> Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
> I measure 8 bytes per Object and 16 bytes per Object[].

That could just be a consequence of wanting 8-byte alignment (although
undoubtedly some use could then be found for the extra bits).

> For java version "1.2" (build )
> Classic VM (build 1.2.2, build Linux_JDK_1.2.2_RC4, native threads, nojit)
> I get 16.24 bytes per Object and 16.24 bytes per Object[].

This is a handle-based system, so you immediately get one more word
for the object pointer in the handle.  Since Sun put the class info in
the handle (makes sense for dispatch speed), the object blocks need a
separate length field, so it's two words of handle and two words of
header.
-- 
Pekka P. Pirinen
Adaptive Memory Management Group, Harlequin Limited