List of utility methods to do ByteBuffer Clean
void | callCleaner(ByteBuffer byteBuffer) Perform "GC" of byte buffer Method cleanerMethod = byteBuffer.getClass().getMethod("cleaner"); cleanerMethod.setAccessible(true); Object cleaner = cleanerMethod.invoke(byteBuffer); Method cleanMethod = cleaner.getClass().getMethod("clean"); cleanMethod.setAccessible(true); cleanMethod.invoke(cleaner); |
void | cleanBuffer(final ByteBuffer bb) clean Buffer bb.rewind(); int remain = 0; while ((remain = bb.remaining()) > 0) { final int r = remain & 0x7; if (r == 0) { bb.putLong(0L); } else { if ((r & 0x4) != 0) { ... |
void | cleanDirectBuffer(ByteBuffer buffer) Force to unmap direct buffer if the buffer is no longer used. if (buffer == null) { return; if (buffer.isDirect()) { Cleaner cleaner = ((DirectBuffer) buffer).cleaner(); cleaner.clean(); |
void | cleanMemBuff(MappedByteBuffer buffer) clean Mem Buff ((DirectBuffer) buffer).cleaner().clean(); |
Method | getCleanerMethod(final ByteBuffer buffer) get Cleaner Method Method result = cleanerMethodCache.get(buffer.getClass()); if (result == null) { result = buffer.getClass().getMethod("cleaner", (Class[]) null); result.setAccessible(true); cleanerMethodCache.put(buffer.getClass(), result); return result; |