/** * Return an estimate of the amount of heap memory used for the object. * If it is not a byte[] then account for CachedDeserializable overhead. * when it is wrapped by a CachedDeserializable. */ public static int calcMemSize(Object o) { return calcMemSize(o, null, true); } public static int calcMemSize(Object o, ObjectSizer os, boolean addOverhead) {
/** * Return an estimate of the amount of heap memory used for the object. * If it is not a byte[] then account for CachedDeserializable overhead. * when it is wrapped by a CachedDeserializable. */ public static int calcMemSize(Object o) { return calcMemSize(o, null, true); } public static int calcMemSize(Object o, ObjectSizer os, boolean addOverhead) {
public static int calcMemSize(Object o, ObjectSizer os, boolean addOverhead) { return calcMemSize(o, os, addOverhead, true); } /**
public static int calcMemSize(Object o, ObjectSizer os, boolean addOverhead) { return calcMemSize(o, os, addOverhead, true); } /**
private int sizeOf(Object obj) { int size = 0; if (obj == null) { return size; } if (obj instanceof String) { size = ObjectSizer.DEFAULT.sizeof(obj); } else if (obj instanceof Integer) { size = 4; //estimate } else if (obj instanceof Long) { size = 8; //estimate } else { size = CachedDeserializableFactory.calcMemSize(obj) - Sizeable.PER_OBJECT_OVERHEAD; } return size; }
private int sizeOf(Object obj) { int size = 0; if (obj == null) { return size; } if (obj instanceof String) { size = ObjectSizer.DEFAULT.sizeof(obj); } else if (obj instanceof Integer) { size = 4; // estimate } else if (obj instanceof Long) { size = 8; // estimate } else { size = CachedDeserializableFactory.calcMemSize(obj) - Sizeable.PER_OBJECT_OVERHEAD; } return size; }
private int sizeOf(Object obj) { int size = 0; if (obj == null) { return size; } if (obj instanceof String) { size = ObjectSizer.DEFAULT.sizeof(obj); } else if (obj instanceof Integer) { size = 4; // estimate } else if (obj instanceof Long) { size = 8; // estimate } else { size = CachedDeserializableFactory.calcMemSize(obj) - Sizeable.PER_OBJECT_OVERHEAD; } return size; }
private int sizeOf(Object obj) { int size = 0; if (obj == null) { return size; } if (obj instanceof String) { size = ObjectSizer.DEFAULT.sizeof(obj); } else if (obj instanceof Integer) { size = 4; // estimate } else if (obj instanceof Long) { size = 8; // estimate } else { size = CachedDeserializableFactory.calcMemSize(obj) - Sizeable.PER_OBJECT_OVERHEAD; } return size; }
private int sizeOf(Object obj) { int size = 0; if (obj == null) { return size; } if (obj instanceof String) { size = ObjectSizer.DEFAULT.sizeof(obj); } else if (obj instanceof Integer) { size = 4; // estimate } else if (obj instanceof Long) { size = 8; // estimate } else { size = CachedDeserializableFactory.calcMemSize(obj) - Sizeable.PER_OBJECT_OVERHEAD; } return size; }
public int getSizeInBytes() { int size = CONSTANT_MEMORY_OVERHEAD; // The value (a byte[]) if (this._value != null) { size += CachedDeserializableFactory.calcMemSize(this._value); } // The sizeOf call gets the size of the input callback argument. size += sizeOf(getOriginalCallbackArgument()); return size; }
public int getSizeInBytes() { int size = CONSTANT_MEMORY_OVERHEAD; // The value (a byte[]) if (this._value != null) { size += CachedDeserializableFactory.calcMemSize(this._value); } // The sizeOf call gets the size of the input callback argument. size += sizeOf(getOriginalCallbackArgument()); return size; }
static int calcMemSize(Object value) { if (value != null && (value instanceof GatewaySenderEventImpl)) { return ((GatewaySenderEventImpl)value).getSerializedValueSize(); } if (value == null || value instanceof Token) { return 0; } if (!(value instanceof byte[]) && !(value instanceof CachedDeserializable) && !(value instanceof com.gemstone.gemfire.Delta) && !(value instanceof Delta)) { // ezoerner:20090401 it's possible this value is a Delta throw new InternalGemFireError("DEBUG: calcMemSize: weird value (class " + value.getClass() + "): " + value); } try { return CachedDeserializableFactory.calcMemSize(value); } catch (IllegalArgumentException e) { return 0; } }
static int calcMemSize(Object value) { if (value == null || value instanceof Token) { return 0; } if (!(value instanceof byte[]) && !CachedDeserializableFactory.preferObject() && !(value instanceof CachedDeserializable) && !(value instanceof com.gemstone.gemfire.Delta) && !(value instanceof Delta)) { // ezoerner:20090401 it's possible this value is a Delta throw new InternalGemFireError("DEBUG: calcMemSize: weird value (class " + value.getClass() + "): " + value); } try { return CachedDeserializableFactory.calcMemSize(value); } catch (IllegalArgumentException e) { return 0; } } }
public int getSerializedValueSize() { @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE) Object vo = this.valueObj; if (vo instanceof StoredObject) { return ((StoredObject) vo).getSizeInBytes(); } else { return CachedDeserializableFactory.calcMemSize(getSerializedValue()); } }
public int getSerializedValueSize() { @Unretained(OffHeapIdentifier.GATEWAY_SENDER_EVENT_IMPL_VALUE) Object vo = this.valueObj; if (vo instanceof StoredObject) { return ((StoredObject) vo).getSizeInBytes(); } else { return CachedDeserializableFactory.calcMemSize(getSerializedValue()); } }
/** * Compute an estimate of the size of the old value * * @return the size of serialized bytes for the old value */ public int getOldValSize() { int oldSize = 0; if (hasOldValue()) { try { oldSize = CachedDeserializableFactory.calcMemSize(basicGetOldValue()); } catch (IllegalArgumentException iae) { logger.warn(LocalizedMessage.create(LocalizedStrings.EntryEventImpl_DATASTORE_FAILED_TO_CALCULATE_SIZE_OF_OLD_VALUE), iae); oldSize = 0; } } return oldSize; }
private long getEntryOverhead(RegionEntry entry) { long entryOverhead = ReflectionSingleObjectSizer.INSTANCE.sizeof(entry); Object key = entry.getRawKey(); if (key != null) { entryOverhead += CachedDeserializableFactory.calcMemSize(key); } else { // first key. Object firstKey = this.getRegionMap().keySet().iterator().next(); if (firstKey != null) { entryOverhead += CachedDeserializableFactory.calcMemSize(firstKey); } } if (entry instanceof DiskEntry) { DiskId diskId = ((DiskEntry) entry).getDiskId(); if (diskId != null) { entryOverhead += ReflectionSingleObjectSizer.INSTANCE.sizeof(diskId); } } return entryOverhead; }
static int calcMemSize(Object value) { if (value == null || value instanceof Token) { return 0; } if (value instanceof GatewaySenderEventImpl) { return ((GatewaySenderEventImpl)value).getSerializedValueSize(); } if (!(value instanceof byte[]) && !CachedDeserializableFactory.preferObject() && !(value instanceof CachedDeserializable) && !(value instanceof com.gemstone.gemfire.Delta) && !(value instanceof Delta)) { // ezoerner:20090401 it's possible this value is a Delta throw new InternalGemFireError("DEBUG: calcMemSize: weird value (class " + value.getClass() + "): " + value); } try { return CachedDeserializableFactory.calcMemSize(value); } catch (IllegalArgumentException e) { return 0; } }
private long getEntryOverhead(RegionEntry entry) { long entryOverhead = ReflectionSingleObjectSizer.INSTANCE.sizeof(entry); Object key = entry.getRawKey(); if (key != null) { entryOverhead += CachedDeserializableFactory.calcMemSize(key); } if (entry instanceof DiskEntry) { DiskId diskId = ((DiskEntry)entry).getDiskId(); if (diskId != null) { entryOverhead += ReflectionSingleObjectSizer.INSTANCE.sizeof(diskId); } } return entryOverhead; } }
/** * Compute an estimate of the size of the old value * * @return the size of serialized bytes for the old value */ public final int getOldValSize() { int oldSize = 0; if (hasOldValue()) { try { oldSize = CachedDeserializableFactory.calcMemSize(basicGetOldValue()); } catch (IllegalArgumentException iae) { this.region.getCache().getLoggerI18n().warning(LocalizedStrings.EntryEventImpl_DATASTORE_FAILED_TO_CALCULATE_SIZE_OF_OLD_VALUE, iae); oldSize = 0; } } return oldSize; }