“This is the 11th day of my participation in the August More Text Challenge. For details, see: August More Text Challenge.”

The introduction

How about what are the jVM memory area in front of the division, what time will be out of memory exception, learned the basic environment of grassland, we enter the Wolf’s chapters, waiting for you is beside the point, this have what relation with the Wolf, because if the compared objects to the sheep, the garbage collection is a pack of wolves, Wolf to limit the number of sheep, guarantee the natural normal operation, in Mongolia, Wolves are gods, and when people die, they feed their bodies to wolves. Wolves are mysterious beings in their eyes. Similarly, our recycling has many mysteries to be solved.

An overview of the

In fact, the first garbage collection was not born in The Java language, the first is the Massachusetts Lisp (ah ah, how American), and yes, admit it, this is the language of dynamic memory allocation and garbage collection technology in 1960, but it really comes down to the fact that garbage collection solves three main problems: when to recycle? Which one should I recycle? How do you recycle?

Why to learn (why)?

Because of the usual need to check for a variety of memory overflow and leakage problems, and high concurrency scenarios need to be necessary monitoring and adjustment of garbage collection.

Reclaim which

There are three blocks of memory in Java that have the same lifetime as a thread. They are: Program counter, local method and the virtual machine stack, we know that each method’s execution will create a stack frame in the stack by thread, along with method calls and the end of the stack and the stack operation, each the size of the stack frame can be identified, namely, the area know yourself, so we didn’t consider the garbage collection of objects.

That left heap and method area, this two area in the mind did not count, you have a question where did not count these two, then I ask you oh (in all seriousness), method area is what? Do you know how many implementation classes there are for an interface? How much memory does each class have? How many arguments are used in the method? How much memory and how many objects are created? So, these two fast regions have significant uncertainty and need to dynamically allocate memory.

digression

Go all out just is to oneself real world live up to, do anything should go all out, what call go all out?

“Wolf Totem” has such a description: if you want to live in the prairie, you must be smarter than the Wolf, more powerful than the Wolf.

Who dare and wolves fight ah, I can assure you met will shiver, the sharp eyes can let your soul shake a shake, but you can stable you anxious heart, you are not afraid, not afraid of you, still can and it in the eye, understanding, also can use what they have learned and combat it, if failure, also can summarize experience again, until the victory over it, this is called out.

In fact, every one of us has a Wolf in our mind, slowly understand it, close to it, close to it, and finally tame it (how kind of sealed inside the body of a nine tail feeling), yes, it will become your strength, with you in battle.