List of usage examples for io.netty.util.internal PlatformDependent freeDirectBuffer
public static void freeDirectBuffer(ByteBuffer buffer)
From source file:docet.DocetUtils.java
License:Apache License
private static void forceReleaseBuffer(ByteBuffer buffer) { if (buffer == null || !buffer.isDirect()) { return;//from ww w. j av a 2s .c om } PlatformDependent.freeDirectBuffer(buffer); }
From source file:herddb.utils.FileUtils.java
License:Apache License
public static void forceReleaseBuffer(ByteBuffer buffer) { if (buffer == null || !buffer.isDirect()) { return;/* w w w . j a v a 2 s. c o m*/ } PlatformDependent.freeDirectBuffer(buffer); }
From source file:herddb.utils.ODirectFileInputStream.java
License:Apache License
@Override public void close() throws IOException { fc.close(); PlatformDependent.freeDirectBuffer(originalBuffer); }
From source file:herddb.utils.ODirectFileOutputStream.java
License:Apache License
@Override public void close() throws IOException { // this will add padding flush(true);/*from w w w . j a v a2s .c om*/ fc.close(); PlatformDependent.freeDirectBuffer(originalBuffer); }
From source file:herddb.utils.OpenFileUtils.java
License:Apache License
public static void releaseAlignedBuffer(ByteBuffer buffer) { PlatformDependent.freeDirectBuffer(buffer); }
From source file:io.horizondb.io.files.FileUtils.java
License:Apache License
/** * Unmap the specified memory mapping.//w w w. j av a2 s . co m * * @param buffer the buffer representing the memory mapping. */ public static void munmap(MappedByteBuffer buffer) { PlatformDependent.freeDirectBuffer(buffer); }
From source file:org.apache.activemq.artemis.core.io.mapped.MappedByteBufferCache.java
License:Apache License
public void closeAndResize(long length) { if (!closed) { //TO_FIX: unmap in this way is not portable BUT required on Windows that can't resize a memmory mapped file! for (final WeakReference<MappedByteBuffer> mbbRef : this.byteBuffers) { if (mbbRef != null) { final MappedByteBuffer mbb = mbbRef.get(); if (mbb != null) { try { PlatformDependent.freeDirectBuffer(mbb); } catch (Throwable t) { //TO_FIX: force releasing of the other buffers }//from w w w . java 2s . c o m } } } this.byteBuffers.clear(); try { if (fileChannel.size() != length) { try { synchronized (FILE_LOCK) { try (FileLock lock = fileChannel.lock()) { final long size = fileChannel.size(); if (size != length) { raf.setLength(length); } } } } catch (IOException ioe) { throw new IllegalStateException("Failed to resize to " + length, ioe); } } } catch (IOException ex) { throw new IllegalStateException("Failed to get size", ex); } finally { try { fileChannel.close(); } catch (IOException e) { throw new IllegalStateException("Failed to close channel", e); } finally { try { raf.close(); } catch (IOException e) { throw new IllegalStateException("Failed to close RandomAccessFile", e); } } closed = true; } } }
From source file:org.apache.activemq.artemis.core.io.mapped.MappedByteBufferCache.java
License:Apache License
@Override public void close() { if (!closed) { //TO_FIX: unmap in this way is not portable BUT required on Windows that can't resize a memory mapped file! for (final WeakReference<MappedByteBuffer> mbbRef : this.byteBuffers) { if (mbbRef != null) { final MappedByteBuffer mbb = mbbRef.get(); if (mbb != null) { try { PlatformDependent.freeDirectBuffer(mbb); } catch (Throwable t) { //TO_FIX: force releasing of the other buffers }//from www . j ava2s . co m } } } this.byteBuffers.clear(); try { fileChannel.close(); } catch (IOException e) { throw new IllegalStateException("Failed to close channel", e); } finally { try { raf.close(); } catch (IOException e) { throw new IllegalStateException("Failed to close RandomAccessFile", e); } } closed = true; } }
From source file:org.apache.activemq.artemis.core.io.mapped.MappedFile.java
License:Apache License
@Override public void close() { try {/* w w w . j a v a2 s . com*/ channel.close(); } catch (IOException e) { throw new IllegalStateException(e); } finally { //unmap in a deterministic way: do not rely on GC to do it PlatformDependent.freeDirectBuffer(this.buffer); } }
From source file:org.apache.activemq.artemis.core.io.mapped.MappedSequentialFileFactory.java
License:Apache License
@Override public void releaseDirectBuffer(ByteBuffer buffer) { PlatformDependent.freeDirectBuffer(buffer); }