Package org.omegat.util
Class MemoryUtils
java.lang.Object
org.omegat.util.MemoryUtils
Utils for calculate used memory.
Calculation of object size is not perfect. It doesn't support multiple links
to one object instance(object shares), memory alignments.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longcalcObjectSize(Object obj) Calculate memory usage for object.static longGet memory allocated by jvm.static intGet memory allocated by jvm.static longgetMemory which is free by jvm.static longgetMemory which is free by jvm.static longGet maximum memory which can be allocated by jvm.static longGet maximum memory which can be allocated by jvm.static longGet memory which used by jvm.
-
Method Details
-
getMemoryUsed
public static long getMemoryUsed()Get memory which used by jvm.- Returns:
- memory size
-
getMemoryFreeMB
public static long getMemoryFreeMB()getMemory which is free by jvm.- Returns:
- free memory size in MB.
-
getMemoryFree
public static long getMemoryFree()getMemory which is free by jvm.- Returns:
- free memory size
-
getMemoryAllocatedMB
public static int getMemoryAllocatedMB()Get memory allocated by jvm.- Returns:
- memory size in MB.
-
getMemoryAllocated
public static long getMemoryAllocated()Get memory allocated by jvm.- Returns:
- memory size
-
getMemoryLimitMB
public static long getMemoryLimitMB()Get maximum memory which can be allocated by jvm.- Returns:
- memory size in MB.
-
getMemoryLimit
public static long getMemoryLimit()Get maximum memory which can be allocated by jvm.- Returns:
- memory size
-
calcObjectSize
Calculate memory usage for object.- Parameters:
obj- object- Returns:
- memory size, or -1 if size is unknown
-