2.1. Native Memory
Native memory is the memory which is available to a process,
e.g. the Java process. Native memory is controlled by the operating
system (OS) and based on physical memory and other physical devices,
e.g. disks, flash memory, etc.
The processor (CPU) of the computer computes the instructions
to execute and stores its computation results into registers. These
registers are fast memory elements which stores the result of the
CPU. The processor can access the normal memory over the memory bus.
A amount of memory a CPU can access is based on the size of the
physical address which the CPU uses to identify physical memory. A
16-bit address can access 2^16 (=65.536) memory locations. A 32-bit
address can access 2^32 (=4.294.967.296) memory locations. If each
memory area consists of 8 bytes then a 16-bit system can access 64KB
of memory and the 32-bit system can access 4GB of memory.
An OS normally uses virtual memory to map the physical memory
to memory which each process can see. The OS assigns then memory to
each process in a virtual memory space for this process and maps
access to this virtual memory to the real physical memory.
Current 32-bit systems uses an extension (Physical Address
Extension (PAE)) which extends the physical space to 36-bits of the
operation system. This allows the OS to access 64GB. The OS uses then
virtual memory to allow the individual process 4 GB of memory. Even
with PAE enabled a process can not access more then 4 GB of memory.
Of course with a 64-bit OS this 4GB limitation does not exists
any more.
Java manages the memory for use. New objects created and placed
in the heap. Once your application have no reference anymore to an
objects the Java garbage collector is allowed to delete this object
and remove the memory so that your application can use this memory
again.
In the heap the Java Virtual Machine (JVM) stores all objects
created by the Java application, e.g. by using the "new" operator.
The Java garbage collector (gc) can logically separate the heap into
different areas, so that the gc can faster identify objects which can
get removed
The memory for new objects is allocated on the heap at run time. Instance variables live inside the object in which they are declared.
The memory for new objects is allocated on the heap at run time. Instance variables live inside the object in which they are declared.