/** * @see org.apache.wicket.util.lang.Objects.IObjectSizeOfStrategy#sizeOf(java.lang.Object) */ public long sizeOf(Object object) { if (object == null) { return 0; } try { final ByteCountingOutputStream out = new ByteCountingOutputStream(); new ObjectOutputStream(out).writeObject(object); out.close(); return out.size(); } catch (IOException e) { return -1; } }
/** * @see org.apache.wicket.util.lang.Objects.IObjectSizeOfStrategy#sizeOf(java.lang.Object) */ public long sizeOf(Object object) { if (object == null) { return 0; } try { final ByteCountingOutputStream out = new ByteCountingOutputStream(); new ObjectOutputStream(out).writeObject(object); out.close(); return out.size(); } catch (IOException e) { if (log.isWarnEnabled()) { log.warn("Unable to determine object size: " + object.toString(), e); } return -1; } }