Although I am also a PHP learner, but did not really understand the PHP internal garbage collection process, just in our code with unset,null,mysql_close,__destruct and so on some functions to release the object to prevent memory overflow, so online GG, Here are some instructions to make a note "PHP can automate memory management to clear objects that are no longer needed." PHP uses the simple
For example-The following is a clear reflection of operating system bugs, in the case of parallel GC, approximately should be the number of user/gc threads = Real[GC [psyounggen:6144000k->423839k (7168000K)] 6455356k->735195k (15360000K),182.4565520secs] [times:user=1.71sys=1454.44, real=182.43secs]--YoungGC, a total of 7168000K size, used 6144000K before collection, followed by 423839K, total time 182
even more pronounced.G1 throughput and pause performance are very good, and are still constantly improving, while the CMS has been marked as obsolete in JDK 9 (deprecated), so the G1 GC is worth your deep mastery.Collection of principles and basic conceptual object instances for garbage collectionAutomatic garbage collection is a prerequisite for knowing which m
Traditional garbage collection mechanism
1. Reference count (RC)
Algorithm
Before 1960, when people designed the garbage collection mechanism for The LISP Language in the embryo, the first algorithm that came to mind was to reference the counting algorithm. Take napkin as an exam
similar to recovering objects in the Java heap. Take the collection of literals in a constant pool as an example, for example, a string "ABC" has entered a constant pool, but the current system does not have any string object called "abc", in other words, there is no string object referencing the "ABC" constant in the constant pool, There is no other reference t
importantly, the circular reference cannot be deleted (for example, two objects are referenced to each other ).
Other methods involve the concept of root set. In short, it refers to the object reference in the stack and the set of objects in the heap. From these objects, we can trace all live objects at the first level. "Any object referred to by a root is reachable and is therefore a live object. additionally, any objects referred to by a live obje
GC Optimization Options
Options
Description
-xms
Initial heap Memory size
-xmx
Maximum heap memory size
-xmn
The size of the young generation
-xx:permsize
The size of the initial permanent generation
-xx:maxpermsize
The largest permanent generation of the size
Example Usage of the JVM GC Optionsjava -X
1. PrefaceGarbage collector is the previous chapter of the garbage collection algorithm theoretical knowledge of the specific implementation of the different virtual machines provided by the garbage collector may be a great difference, and we must explain in advance that there is no best garbage collector, more than a
Java's garbage collection has a variety of strategies, and the default policy is often changed.-for example, serial, parallel, CMS; How about the concrete to Minor, old?
Command java-xx:+printflagsfinal-version, providing help:
BOOL USEPARNEWGC false {product} bool USEPARALLELGC
objects are neither static variables nor local variables, instead, all allocated memory blocks in the heap.
Reference Counting AlgorithmBefore 1960, when people designed a garbage collection mechanism for The LISP Language in the embryo, the first algorithm that came to mind was to reference the counting algorithm. Taking napkin as an example, the principle of
space they occupy will be reclaimed for allocation to new objects.
To understand the garbage collection mechanism and the various garbage collection algorithms, you first need to know some knowledge about the Java Platform memory model.
Garbage
Purge and reference count. Reference counts are less common, and tag cleanup is more commonly used.Second, Mark ClearThe most common way of garbage collection in JS is to mark clear. When a variable enters the environment, for example, when a variable is declared in a function, the variable is marked as "going into the environment." Logically, it is never possib
for garbage collection, and the other is used for user threads. In this case, there were two CPUs running user threads. Now there is one thread, and the efficiency will drop sharply. That is to say, the throughput is reduced (that is, the CPU usage is reduced ).
Concurrent cleanup: In this process, the generated garbage cannot be cleared (because it occurs afte
attribute to obtain the highest algebra of GC. Currently, the highest generation is set value 2.
You can call the GC. Collect () method to force the Garbage Collector to perform garbage collection. The collect method has two reloads:
Void GC. Collect (int32 generation) void GC. Collect ()
The first method allows you to specify the generation to be recycled.
The current commercial virtual machine garbage collection uses the "generational collection" algorithm, that is, according to the different life cycle of the object, divided into several pieces of memory, generally for the Cenozoic and the old era, different generations according to its characteristics of the use of the most appropriate
the entire managed heap. The method without parameters calls GC. Collect (GC. MaxGeneration) is equivalent to the whole collection. In general, the GC. Collect method should not be called; it is best to let the Garbage Collector determine when to call the Collect method according to its own algorithm. Even so, if you are more confident that you know when to do garbage
is less common, and mark removal is more common.
Second, Mark Clear
The most common way of garbage collection in JS is Mark removal. When a variable enters the environment, for example, when declaring a variable in a function, it marks the variable as "entering the environment." Logically, the memory occupied by variables entering the environment can never be
domains to optimize performance.Parallel collectorThe parallel collector uses some traditional algorithms and uses multithreading to perform their work in parallel. The use of multithreading on multi-CPU machines can significantly improve the scalability of Java applications.Finally, a very simple example of a tracking collector is posted so that you can deepen your understanding of the collector:Trace collector legendWhere to pay attention to using
I. Understanding the meaning of garbage collectionAfter more than half a century of development, the current memory dynamic allocation and memory recovery technology has been quite mature, everything seems to have entered the "era of automation", then why we have to study and to understand the GC and memory allocation. The answer is simple: when you need to troubleshoot various memory overflows, memory leaks, and when
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.