ucar.unidata.idv
Class SystemMemoryManager

java.lang.Object
  extended by ucar.unidata.idv.SystemMemoryManager

public class SystemMemoryManager
extends Object

Global to deal with IDV command line memory settings.


Field Summary
static long MINIMUM_MEMORY
          Minimum memory for the IDV.
 
Method Summary
static long checkAndRepair(long memory)
          Check and repair memory settings
static long convertToNumber(int percent)
          Convenience method.
static float convertToPercent(long memory)
          Convenience method.
static long getDefaultMemory()
          The default when the user first starts up should be to use 80% between the "low and high-water mark", but they should be allowed to increase that to 100% of the high-water mark.
static long getTotalMemory()
          For 32 bit OS, the total should be the minimum of the (total system memory - 512Mb) and 1536MB.
static boolean isMemoryAvailable()
          Checks if is memory is available for this JVM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM_MEMORY

public static final long MINIMUM_MEMORY
Minimum memory for the IDV.

See Also:
Constant Field Values
Method Detail

isMemoryAvailable

public static boolean isMemoryAvailable()
Checks if is memory is available for this JVM.

Returns:
true, if memory is available

getTotalMemory

public static long getTotalMemory()
For 32 bit OS, the total should be the minimum of the (total system memory - 512Mb) and 1536MB. On 64-bit systems, it should be the total system memory-512Mb. If the total system memory is not available -1. Probably should call isMemoryAvailable() first. Must return at least 512.

Returns:
Return the total memory in megabytes, if available.

getDefaultMemory

public static long getDefaultMemory()
The default when the user first starts up should be to use 80% between the "low and high-water mark", but they should be allowed to increase that to 100% of the high-water mark. There are a couple of exceptions to the 80% heuristic. The amount of memory returned will never be < 512GB. Also, if on 32 bit OS be conservative and choose 70%. For example, if we have 32 bit windows with 1536 of memory, the result will be 1229.

Returns:
the default memory

convertToPercent

public static float convertToPercent(long memory)
Convenience method. Convert memory to percent.

Parameters:
memory - the memory
Returns:
the percent or -1

convertToNumber

public static long convertToNumber(int percent)
Convenience method. Convert memory percent to number.

Parameters:
percent - the percent
Returns:
the number or -1

checkAndRepair

public static long checkAndRepair(long memory)
Check and repair memory settings

Parameters:
memory - the memory setting
Returns:
the memory (fixed if necessary).