cowtowncoder/java-merge-sort — Issue #1: Add helper methods for calculating approximate object mem usage
Author: cowtowncoder
Created: 2011-12-11 04:35:46+00:00
State: open

Currently there is no support for estimating sortable entry lengths. It would be nice to have helper object to use for calculating object sizes: this can use conservative estimates, like:

* Each object has some base per-instance overhead (say, 16 bytes)
* Arrays also have base overhead (possibly less than Objects, but let's say 16 bytes) -- but also per-entry overhead (4 or 8 byte per reference type, 1/2/4/8 bytes for primitives)
* Fields and array entries could perhaps be combined

We should probably have separate instances for 32-/64-bit machines; but can let caller specify which one is wanted.

Since this object is performance sensitive will probably need to keep it stateless (i.e. caller must pass all data as arguments), instead of using builder-style (which otherwise would be nice).