Object-oriented memory management ---

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_44779847/article/details/102732859

Object-oriented - Memory Management

1. Memory Management: Management by the JVM
) stack 1:
1.1) out of the store new objects (including instance variables)
1.2) Garbage: no object reference points to
the garbage collector (GC) from time to time into memory scavenging,
recycling process is transparent (not visible),
do not necessarily find a garbage recycling immediately,
call System.gc () may suggest a virtual machine scheduling GC as soon as possible to recover
1.3) memory leak: memory no longer in use have not been timely recycling
advice: when the object is no longer used in a timely manner sets the reference to null
1.4) life cycle instance variables:
when creating objects stored on the heap, and a recovery when the object is recovered
2) stack:
2.1 storage method is invoked) All local variables (including method arguments)
of the stack frame allocated for the method will correspond 2.2) when calling a method in the stack,
the stack frame is stored in a local variable in the method (including the parameters of the method),
at the end of the method call stack frames are cleared, together with local variables failure
life cycle 2.3) local variables:
the stack, with the end of the process the stack frame and a remove method is called memory
3) method area:
3.1) bytecode file storage .class (including static variables Method)
3.2) is only a method to distinguish objects by this specific call

Guess you like

Origin blog.csdn.net/qq_44779847/article/details/102732859