Program Counter
Recording bytecode instruction address, small footprint, no exception is thrown substantially
Native method stacks
native method area
Methods district
Shared by all threads, the main information storage classes, constant pool, method data, the method code.
Heap
JVM shared by all threads, all objects and arrays are allocated on the heap, this memory can be recovered by GC, are not eligible for memory space throwsOutOfMemoryError
VM stack
Thread private, with the creation of threads created, stored inside the stack "stack frame", each method will store a stack frame, stack frames stored in the local variable table, the operand stack method exports. It throws StackOverflowError
,OutOfMemoryError
PermGen on behalf of non-permanent
Common abnormalities java.lang.OutOfMemoryError: PermGen space
, in fact, refers to the method area, but the method area and there are essential differences PermGen. The former is the JVM specification, which is an implementation of the JVM specification, and only have a HotSpot PermGen space
.
JDK1.8 been substituted with Metaspace PermGen
Metaspace (dimensional space)
MetaSpace permanent nature and to similar, are achieved in the method area the JVM specification. And do not give Metaspace PermGen biggest difference is that: Yuan is not space in a virtual machine, but the use of local memory. Thus metadata only by the size of the local memory limits
-XX: MetaspaceSize, the initial size of the space, this value is reached will trigger the type unloading garbage collection, while the GC will adjust the value; if the release of a large amount of space, it is appropriate to reduce the value; if the release very little space then when no more than MaxMetaspaceSize, an appropriate increase in the value.
-XX: MaxMetaspaceSize default maximum space is no limit.
Why do PermGen converted to Metaspace
1. string in the permanent generation, performance problems and prone to memory overflow.
2. Class information and methods and other more difficult to determine the size, and therefore more difficult to specify the size of the permanent generation, too prone to permanent generation of overflow, too easily lead to overflow years old.
3. permanent generation will bring unnecessary complexity for the GC, and recovery efficiency is low.
4.Oracle might HotSpot combined with JRockit.