Java heap, Native memory and Process size
Java heap:
This is the memory that the JVM uses to allocate java objects. The maximum value of java heap memory
is specified using the -Xmx flag in the java command line. If the maximum heap size is not specified, then the limit is decided by the JVM considering factors like the amount of physical memory in the machine and the amount of free memory available at that moment. It is always recommended to specify the max java heap value.
Native memory
This is the memory that the JVM uses for its own internal operations. The amount of native memory heap that will be used by the JVM depends on the amount of code generated, threads created, memory used during GC for keeping java object information and temporary space used during code generation, optimization etc. If there is a third party native module, it could also use the native memory. For example, native JDBC drivers allocate native memory.
The max amount of native memory is limited by the virtual process size limitation on any given OS and the amount of memory already committed for the java heap with -Xmxflag. For example, if the application can allocate a total of 3 GB and if the max java heap is 1 GB, then the max possible native memory is approximately 2 GB.
Process size:
Process size will be the sum of the java heap, native memory and the memory occupied by the loaded
executables and libraries. On 32-bit operating systems, the virtual address space of a process can go up to 4 GB. Out of this 4 GB, the OS kernel reserves some part for itself (typically 1 - 2 GB). The remaining is available for the application.
No comments:
Post a Comment