org.jnetpcap.nio
Class JReference
java.lang.Object
org.jnetpcap.nio.JMemory
org.jnetpcap.nio.JStruct
org.jnetpcap.nio.JReference
public class JReference
- extends JStruct
A specialized class that is used for managing JNI global object references.
Global JNI references once allocated need to be explicitely deallocated or
they will always hold on to the the java object reference preventing the
objects of ever going out of scope. This class allows a native structure to
create and use global JNI references while JReference class keeps track of
the created references for deallocation purposes when the time comes.
This class is internally maintained by JMemory and the user usually does not
have to ever deal with it directly. References are maintained automatically.
References objects are transfered during the peering and copy process just
like JMemory keeper objects. This makes sure that JNI global references are
not released too soon but are when the last object using them is GCed. The
references array is a native structure, peered with JReference from JNI
space.
- Author:
- Mark Bednarczyk, Sly Technologies, Inc.
|
Constructor Summary |
JReference()
This type of structure is always allocated natively and peered with a java
counter part. |
|
Method Summary |
protected void |
cleanup()
Called to clean up and release any allocated memory. |
int |
getCapacity()
|
java.lang.String |
toDebugString()
Returns a debug string about this JMemory state. |
| Methods inherited from class org.jnetpcap.nio.JMemory |
check, finalize, isInitialized, isJMemoryBasedOwner, isOwner, peer, peer, peer, setSize, size, toHexdump, toHexdump, totalActiveAllocated, totalAllocateCalls, totalAllocated, totalAllocatedSegments0To255Bytes, totalAllocatedSegments256OrAbove, totalDeAllocateCalls, totalDeAllocated, transferFrom, transferFrom, transferFrom, transferFrom, transferFromDirect, transferOwnership, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo, transferTo |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
JReference
public JReference()
- This type of structure is always allocated natively and peered with a java
counter part.
cleanup
protected void cleanup()
- Description copied from class:
JMemory
- Called to clean up and release any allocated memory. This method should be
overriden if the allocated memory is not simply a single memory block and
something more complex. This method is safe to call at anytime even if the
object does not hold any allocated memory or is not the owner of the memory
it is peered with. The method will reset this object to orignal unpeered
state releasing any allocated and own memory at the same time if
neccessary.
- Overrides:
cleanup in class JMemory
toDebugString
public java.lang.String toDebugString()
- Description copied from class:
JMemory
- Returns a debug string about this JMemory state. Example:
JMemory@b052fa8: size=1506, owner=nio.JMemoryPool$Block.class(size=10240/offset=4064)
- hex nuber, is physical memory location
- size = number of bytes of this memory object
- owner = the class name of the object that owns the physical memory
- isOwner = if true, means that this object is the owner of physical
memory
- size in parenthesis = the size of the physical memory allocated by the
owner
- offset in parenthesis = the offset into the physical memory block of
this memory object
- Overrides:
toDebugString in class JMemory
- Returns:
- a summary string describing the state of this memory object
getCapacity
public int getCapacity()