private static ByteBuffer trim ( ByteBuffer buf ) { if ( buf . capacity ( ) <= 4 * buf . remaining ( ) ) { return buf ; } else { ByteBuffer clone = ByteBuffer . allocate ( buf . remaining ( ) ) ; buf . get ( clone . array ( ) ) ; return clone ; } }
Serialized Astyanax Composite objects use a lot of memory . Trim it down .