executed alternately. Each time, the garbage collection thread collects only a small area of memory space, and then switches to the application thread. Repeat until garbage collection is complete. In this way, due to the intermittent execution of the application code during the ga
of root set. The Garbage Collector Based on the tracing algorithm scans the root set to identify which objects are reachable and which objects are not reachable, and marks the reachable objects in some way, for example, you can set one or more places for each reachable object. During scanning and recognition, the tracing algorithm-based garbage
pool is a good example of a memory pool type. The memory pool can belong to a heap or a permanent generation, depending on the implementation of the JVM memory management.Run a constant-rate poolThe run-time constant pool is the runtime representative of each class of const pool. It contains the run-time and static methods of the class. Running a constant pool is part of the method area.Java Stack MemoryJava stack memory is used to run threads. They
root is a reference to the objects contained in the local variables in static variables or active stack frameworks. The reachable object set points to the passing closure of the root set under the link.
Reference count
The most intuitive garbage collection policy is reference count. Reference counting is very simple, but it requires an important combination of the compiler and adds a value assignment.Mutat
= ' righttxthead ' >aft = Re.findall (tmp_reg,content)For url_1 in aft:#继续进入下层地址Content1=get_url (' http://xxxx ' +url_1)# Matching here took a lot of time, there is time to continue to tidy up!#tmp_reg1 = ' TMP_REG1 = ' #. +--this is greed. *? The non-greedy PHP words are/reg/u with whether add U to distinguish# Print Content1# match with FindAll, similar to PHP's preg_match_all but not the same, especially the array structure that returns the resultaft_1 = Re.findall (tmp_reg1,content1)#!!!!!
The garbage collection mechanism is a dynamic storage allocation scheme. It automatically frees allocated blocks of memory that the program no longer needs. The process of automatically reclaiming memory is called garbage collection. The garbage
, for example:
>>> a = set (' Boy ')>>> a.add (' python ')>>> ASet ([' Y ', ' python ', ' B ', ' O '])
Collection Update method: Splits the elements to be passed in to the collection as an individual, for example:
>>> a = set (
still be recycled. For example, objects C and D are referenced by each other, but they are recycled because they cannot access the root.
Jvm uses the root search algorithm to determine whether to recycle objects.
In the root search algorithm, all references are strongly referenced. A strongly referenced link is an object created using the new method and displays the associated objects.
Object obj = new Object();
The above indicates a strong re
The CLR garbage collector divides objects according to the size of the space they occupy. Large objects and small objects are handled in a very different way. For example, memory defragmentation-the cost of moving large objects in memory is expensive, let's look at how the garbage collector handles large objects, and what the potential impact of large objects has
execution time of the garbage collection mechanism when performing memory cleanup (run-time delay). We will look at these two areas.
Savings in memory footprint
First, the whole reason for implementing the garbage collection mechanism is to save memory footprint by cleaning up the variables referenced by the loop on
more advantageous the parallel collector is.
Applicability: medium and large applications with high throughput requirements, multiple CPUs, and no application response time requirements. Example: background processing and scientific computing.
Disadvantage: The application response time may be long.
4. Concurrent collection
Compared with serial collection and pa
does not execute? When not executing is not allocating CPU time, the typical example is sleep or blocked state, the thread can not respond to the JVM's interrupt request, to a safe place to interrupt the suspend, the JVM obviously can not wait for the thread to be reassigned CPU time, this situation needs to take another method-- Security zone safe region to solve.A security zone refers to a code in which the reference relationship does not change. G
English Original: Maoni Stephens, compilation: Zhao Yukai (@ Jade Kai Sir)
The CLR garbage collector divides objects by the amount of space they occupy. Large objects and small objects are handled in a very different way. For example, memory defragmentation-the cost of moving large objects in memory is expensive, so let's look at how the garbage collector handles
. NET garbage collection-Principle AnalysisDuring the development of. NET programs, since the garbage collection mechanism in CLR manages allocated objects, programmers can ignore the time when objects are released. However, it is necessary to understand the garbage
new), and cannot clear the allocated memory on the stack (when using JNI technology, memory may be allocated on the stack, such as Java calling C programs, while the C program allocates memory using malloc). Therefore, if some objects are allocated the memory area on the stack, then the GC is not the case, and the memory of the objects on the stack depends on finalize (). For example, when Java calls a non-Java method (which may be C or C + +), the m
of all the other objects that refer to it. every time an object is assigned or an operation is performed med that wocould alter a reference to an object, the reference count for all involved objects are appropriately updated. if an object's reference count decrements to zero, then it is refreshing tively unreachable and considered "garbage. "though this technique provides a good conceptual example, it is r
:1, Mark elimination Method 2, Replication algorithm 3, marking-finishing algorithm
sub-generation garbage collection algorithm:1, split-collection algorithm
Reference Counting method: in Java, the most direct way to determine whether an object is still needed is to determine if the object has not been referenced. If an object is basically not referenced by any a
objects results in reduced efficiency
Because the processor is multicore now, the performance of the processor has been greatly improved, so on this basis there are several garbage collection algorithms. Mainly includes two kinds of algorithms
Parallel tag Cleanup
The so-called parallel is that the original garbage
The CLR Garbage Collector divides Objects Based on the occupied space. The processing methods for large and small objects are quite different. For example, memory fragmentation-the cost of moving large objects in the memory is expensive. Let's look at how the Garbage Collector handles large objects and what potential impact large objects have on the procedure. La
, the collector does not have the opportunity to start. Therefore, this garbage collection mechanism is not a very reliable mechanism. Because garbage can not be reclaimed in a timely manner, the memory space they occupy cannot be released, which can affect the performance of the program, and if a program generates large amounts of
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service