java memory management 内存管理

Stacks in JVM

  • A running Java thread has a private stack, called the Java method stack
    • has frames of the currently active invocations of methods
    • a frame stores the current values of the local variables, parameters, and information on calling method
  • Program counter maintains the address of currently excuting statement
  • At the top of the Java stack is the frame of the running method,remaining elements of the stack are frames of the suspended methods
  • Using a stack allows programs to use recursion
  • Arithmetic expressions are eveluated by the JVM using an operand stack

    Memory Heap

  • Memory for an object is allocated dynamically by new operator
  • Memory heap is for object’s memory

    Memory Allocation Algorithms

  • Free list: a linked list joining holes of available free memory