Perm space vs Heap space

前端 未结 3 1787
青春惊慌失措
青春惊慌失措 2020-12-07 12:56

First, What is the difference between Perm space and Heap space (What and how does the JVM choose to use each memory space)?

Second, but most importantly, what sort

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 13:52

    The heap stores all of the objects created by your Java program. The heap's contents is monitored by the garbage collector, which frees memory from the heap when you stop using an object (i.e. when there are no more references to the object.

    This is in contrast with the stack, which stores primitive types like ints and chars, and are typically local variables and function return values. These are not garbage collected.

    The perm space refers to a special part of the heap. See this SO answer for an explanation: What is perm space?

提交回复
热议问题