public class Sizeof
extends java.lang.Object
estimator for the size of data structures. The sizes of individual elements used to compute the overall size of a data structure are estimates only derived on 1.4.2 on a 32bit Linux.
The implementation will be changed to
java.lang.instrument.Instrumentation
as soon as we
switch to Java 5.
Modifier and Type | Class and Description |
---|---|
static class |
Sizeof.Pair
a pair of count and size describing use and size of a data type.
|
Modifier and Type | Field and Description |
---|---|
static int |
MEM_ARRAY_OVERHEAD |
static int |
MEM_CHAR_INARRAY |
static int |
MEM_OBJ_OVERHEAD |
static int |
MEM_PTR_SIZE |
Modifier and Type | Method and Description |
---|---|
static int |
charArrayMemEstimate(int numElems) |
static int |
objectArrayMemEstimate(int numElems) |
static void |
printTypes(java.io.PrintStream out,
java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<?>,Sizeof.Pair>> types)
prints the result produced with
sizeof() . |
static int |
roundUp(int l) |
static java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<?>,Sizeof.Pair>> |
sizeof(java.lang.Object o)
recursively delves into the object graph
o and
returns a Hashtable with information about object
sizes and counts. |
public static final int MEM_ARRAY_OVERHEAD
public static final int MEM_PTR_SIZE
public static final int MEM_CHAR_INARRAY
public static int MEM_OBJ_OVERHEAD
public static int charArrayMemEstimate(int numElems)
public static int objectArrayMemEstimate(int numElems)
public static int roundUp(int l)
public static java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<?>,Sizeof.Pair>> sizeof(java.lang.Object o)
o
and
returns a Hashtable
with information about object
sizes and counts. The keys used in the result are
java.lang.Class
objects.
Each key k is mapped to a java.util.Map
object which pairs a class object r and a Sizeof.Pair
. The Pair
describes how often
k appears as a field in an object of type r. In
other words: within the object graph, objects of type r
are parents of objects of type k.public static void printTypes(java.io.PrintStream out, java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<?>,Sizeof.Pair>> types)
sizeof()
.