public class MemoryMappedFile extends NativeMemory
byteBuf_, capacityBytes_, memArray_, memReq_, nativeRawStartAddress_, objectBaseOffset_| Constructor and Description |
|---|
MemoryMappedFile(File file,
long position,
long len)
Constructor for memory mapping a file.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
finalize()
If the JVM calls this method and a "freeMemory() has not been called" a System.err
message will be logged.
|
void |
force()
Forces any changes made to this content to be written to the storage device containing the
mapped file.
|
void |
freeMemory()
This frees this Memory only if it is required.
|
boolean |
isLoaded()
Tells whether or not the content is resident in physical memory.
|
void |
load()
Loads content into physical memory.
|
array, asReadOnlyMemory, byteBuffer, clear, clear, clearBits, copy, copy, fill, fill, getAddress, getAndAddInt, getAndAddLong, getAndSetInt, getAndSetLong, getBoolean, getBooleanArray, getByte, getByteArray, getCapacity, getChar, getCharArray, getCumulativeOffset, getDouble, getDoubleArray, getFloat, getFloatArray, getInt, getIntArray, getLong, getLongArray, getMemoryRequest, getNativeMemory, getParent, getShort, getShortArray, hasArray, hasByteBuffer, isAllBitsClear, isAllBitsSet, isAllocated, isAnyBitsClear, isAnyBitsSet, isDirect, isReadOnly, putBoolean, putBooleanArray, putByte, putByteArray, putChar, putCharArray, putDouble, putDoubleArray, putFloat, putFloatArray, putInt, putIntArray, putLong, putLongArray, putShort, putShortArray, requiresFree, setBits, setMemoryRequest, toHexStringpublic MemoryMappedFile(File file, long position, long len) throws Exception
Memory maps a file directly in off heap leveraging native map0 method used in FileChannelImpl.c. The owner will have read write access to that address space.
file - - File to be mappedposition - - memory map starting from this position in the filelen - - Memory map at most len bytes > 0 starting from positionException - file not found or RuntimeException, etc.public void load()
public boolean isLoaded()
public void force()
If the file mapped into this buffer resides on a local storage device then when this method returns it is guaranteed that all changes made to the buffer since it was created, or since this method was last invoked, will have been written to that device.
If the file does not reside on a local device then no such guarantee is made.
If this buffer was not mapped in read/write mode (java.nio.channels.FileChannel.MapMode.READ_WRITE) then invoking this method has no effect.
public void freeMemory()
NativeMemoryIt is always safe to call this method when you are done with this class.
freeMemory in class NativeMemoryCopyright © 2015–2016 Yahoo! Inc.. All rights reserved.