better memory estimate

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@476065 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Wolfgang Hoschek 2006-11-17 07:29:44 +00:00
parent fb8fd8b8ce
commit 2b1dd87818
1 changed files with 5 additions and 4 deletions

View File

@ -1103,10 +1103,11 @@ public class MemoryIndex {
/**
* Object header of any heap allocated Java object.
* 1 word: ptr to class, 1 word: info for monitor, gc, hash, etc.
* ptr to class, info for monitor, gc, hash, etc.
*/
private static final int HEADER = 2*PTR;
private static final int OBJECT_HEADER = 2*4; // typically even on 64 bit VMs
// private static final int OBJECT_HEADER = 2*PTR;
/**
* Modern VMs tend to trade space for time, allocating memory on word
* boundaries. For example, on a 64 bit VM, the variables of a class with
@ -1132,7 +1133,7 @@ public class MemoryIndex {
}
public static int sizeOfObject(int n) {
return sizeOf(HEADER + n);
return sizeOf(OBJECT_HEADER + n);
}
public static int sizeOfObjectArray(int len) {