|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.icesoft.pdf.util.MemoryManager
The MemoryManager class is a utility to help manage the amount of memory
available to the application. When memory intensive operations are about
occur, the MemoryManager is asked if it can allocate the needed amount of memory.
If there is not enough memory available, the MemoryManager will purge the
cache to try and free the requested amount of memory.
| Field Summary | |
protected long |
cumulativeDurationManagingMemory
|
protected long |
cumulativeDurationNotManagingMemory
|
protected ArrayList |
delegates
|
protected ArrayList |
leastRecentlyUsed
|
protected WeakHashMap |
locked
|
protected long |
maxMemory
The maximum amount of memory allocated to the JVM. |
protected int |
maxSize
If a memory-based ceiling, like maxMemory, is not sufficient, then you can use maxSize to specify the maximum number of items that may be opened before purging commences. |
protected long |
minMemory
The minimum amount of free memory at which the memory manager will force a purge of the cached pageTree. |
protected int |
percentageDurationManagingMemory
|
protected long |
previousTimestampManagedMemory
|
protected int |
purgeSize
When we decide to reduce our memory footprint, this is how many items we purge at once. |
protected Runtime |
runtime
Runtime object responsible for returning VM memory use information |
| Constructor Summary | |
protected |
MemoryManager()
Creates a new instance of a MemoryManager. |
| Method Summary | |
boolean |
checkMemory(int memoryNeeded)
|
long |
getFreeMemory()
Get runtime free memory. |
static MemoryManager |
getInstance()
Get an instance of the MemoryManager. |
long |
getMaxMemory()
Get maximum amount of jvm heap. |
long |
getMinMemory()
Get the minimum amount of memory |
protected boolean |
isLocked(MemoryManageable mm)
|
boolean |
isLowMemory()
Check whether the runtime is low on memory. |
void |
lock(Object user,
MemoryManageable mm)
|
protected boolean |
reduceMemory()
|
protected int |
reduceMemory(int numToDo)
|
protected boolean |
reduceMemoryWithDelegates(boolean aggressively)
|
void |
registerMemoryManagerDelegate(MemoryManagerDelegate delegate)
|
void |
release(Object user,
MemoryManageable mm)
|
void |
releaseAllByLibrary(Library library)
|
static void |
setInstance(MemoryManager memoryMangaer)
Sets an existing MemoryManager object to this
MemoryManager object. |
void |
setMaxMemory(long m)
Set the maximum amount of JVM heap. |
void |
setMinMemory(long m)
Set the minimum amount of memory. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected final Runtime runtime
protected long minMemory
protected long maxMemory
protected int purgeSize
protected int maxSize
protected WeakHashMap locked
protected ArrayList leastRecentlyUsed
protected long cumulativeDurationManagingMemory
protected long cumulativeDurationNotManagingMemory
protected long previousTimestampManagedMemory
protected int percentageDurationManagingMemory
protected ArrayList delegates
| Constructor Detail |
protected MemoryManager()
MemoryManager.
| Method Detail |
public static void setInstance(MemoryManager memoryMangaer)
MemoryManager object to this
MemoryManager object.
memoryMangaer - MemoryManager object to point to.public static MemoryManager getInstance()
MemoryManager. If there is not a MemoryManager
initiated, a new MemoryManager is is created and returned.
MemoryManager object com.icesoft.pdf.minMemory
public void lock(Object user,
MemoryManageable mm)
public void release(Object user,
MemoryManageable mm)
public void registerMemoryManagerDelegate(MemoryManagerDelegate delegate)
public void releaseAllByLibrary(Library library)
protected boolean reduceMemory()
protected int reduceMemory(int numToDo)
protected boolean isLocked(MemoryManageable mm)
protected boolean reduceMemoryWithDelegates(boolean aggressively)
public void setMinMemory(long m)
public long getMinMemory()
public void setMaxMemory(long m)
MemoryManager will use this number to determine whether it
is low on memory. The manager also uses Runtime.freeMemory()
call but that call returns the free memory with only the
current heap size, not the maximum heap size.
public long getMaxMemory()
public long getFreeMemory()
public boolean isLowMemory()
public boolean checkMemory(int memoryNeeded)
memoryNeeded -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||