module:Import Gcprint (Gc.get_threshold ())Return (700, 10, 10), followed by two 10 is the threshold associated with generational collection, which can be seen later. 700 is the threshold at which garbage collection starts. Can be reset by the Set_threshold () method in the GC.We can also start the garbage collection manually, that is, using Gc.collect ().Generational recyclingPython also uses the strategy of generational (generation) recycling. The basic assumption of this strategy is that the
garbage collection starts. Can be reset by the set_threshold () method in the GC.We can also start the garbage collection manually, that is, using gc.collect ().Generational RecyclingPython also uses the strategy of generational (generation) recycling. The basic assumption of this strategy is that the longer the surviving object, the less likely it is to become garbage in later programs. Our programs tend to produce a large number of objects, many objects quickly produce and disappear, but ther
of the Cenozoic, Laosheng generation and durable generations
Gccause
Used to view the statistics of garbage collection (this is the same as the-gcutil option), and if garbage collection occurs, it also shows the reason for the last and current garbage collection.
Gcnew
For viewing new generation garbage collection scenarios
Gcnewcapacity
For viewing the storage capacity of the Cenozoic
executes class bytecode. After the thread is created, the program counter (PC) and stack (stack) are generated, and the program counter holds the offset of the next instruction to be executed in the method, and the stack frames are stored in each stack frame, and each stack frame corresponds to each call of each method, and the stack frame is made up of the local variable area and the operand stack. Local variables are used to store local variables and parameters in the method, which are used t
. and transfer all surviving objects to one of the survivor areas.
The Minor GC also checks for surviving objects and transfers them to another survivor area. In this way, there will always be an empty survivor area for a period of time.
After several GC cycles, the surviving objects are transferred to the old generation memory space. This is usually done by setting an age threshold before the younger generation is eligible to ascend to the old age.
Old Generation Older
mainstream virtual machines are extensible. If you do not have enough memory allocations or extensions after the garbage collection has been performed, you will throw a Outofmemoryerror:java heap space exception.
There is much more to the heap area, which is described in detail in the next section, "Java Memory allocation mechanism."
5, methods area: In the Java Virtual Machine specification, the method area is treated as a logical part of the heap, but in fact, the method area is not a heap (n
mainstream virtual machines are extensible. If you do not have enough memory allocations or extensions after the garbage collection has been performed, you will throw a Outofmemoryerror:java heap space exception.
There is much more to the heap area, which is described in detail in the next section, "Java Memory allocation mechanism."
5, methods area: In the Java Virtual Machine specification, the method area is treated as a logical part of the heap, but in fact, the method area is not a heap (n
extensible when implemented, and the current mainstream virtual machines are extensible. If you do not have enough memory allocations or extensions after the garbage collection has been performed, you will throw a Outofmemoryerror:java heap space exception.
There is much more to the heap area, which is described in detail in the next section, "Java Memory allocation mechanism."
5, methods area: In the Java Virtual Machine specification, the method area is treated as a logical part of the heap,
(1) Parameter
-XMS: initial Heap Size
-XMX: Maximum heap Size This value can be set to be the same as-xmx to avoid the JVM reallocating memory after each garbage collection completes
-XMN: Young Generation size whole heap size = young generation size + older generation size + persistent generation size. The permanent generation generally has a fixed size of 64m, so increasing the younger generation will decrease the size of the older generation. This value has a significant impact on system perf
and therefore have a long lifecycle. But there are some objects, mainly in the process of running the program generated temporary variables, these objects life cycle will be relatively short, such as: string objects, because of its invariant class characteristics, the system will produce a large number of these objects, some objects can be recycled even once.
Just imagine that, without making a distinction between object survival time, each garbage collection is a collection of the entire heap
performance, and Sun officially recommends configuring the 3/8 of the entire heap.-xx:permsize=256m: Set heap Memory persistent generation initial value of 256M. (looks like an initialization parameter for an IDE such as Eclipse)-xx:maxnewsize=size: A newly generated object can occupy the maximum memory value.-XX:MAXPERMSIZE=512M: Set the maximum persistence generation to 512M.-xx:newratio=4: Sets the ratio of the young generation of heap memory (including Eden and two survivor areas) to the ol
. Divide the heap memory into young generations, mature generations, and permanent generations. The generational recycling mechanism uses different recycling strategies in different regions. The young generation was storing the new construction object, using copy and sweep. It is divided into 3 districts, Eden, from district, to district. Eden refers to the area
-monitoring object for synchronization
Held by JVM -objects reserved for the special purpose of the JVM by the GC, but this is actually related to the implementation of the JVM. Some of the types that may be known are the system ClassLoader, the important exception classes that some JVMs know, some pre-allocated objects for handling exceptions, and some custom class loaders. However, the JVM does not provide additional information for these objects, so it is only left to the analyst to
algorithmUse a graph to summarize the layout of the heap memory according to the above contentModern commercial virtual machines are basically using generational collection algorithms for garbage collection. This algorithm is nothing special, but the combination of the above content, according to the different life cycle of the object to divide the memory into several pieces, and then according to the characteristics of each block using the most appropriate collection algorithm. A large number
(),2. When the counter of the GC module reaches the valve value.3. When the program exits
Four. GC Module common function analysis
Garbage Collector interface
The GC module provides an interface for developers to set up garbage collection options. As mentioned above, one of the drawbacks of using reference counting to manage memory is circular references, and one of the main functions of the GC module is to solve the problem of circular references.
Common functions:
Gc.set_debug (Flags)Se
, but the basic is to eliminate the old platform, for Yi Yuan tyrants computer, buy this high power consumption, not cost-effective computer, now really is not worth it!
8692 yuan Intel four Generation i7 single display machine configuration comment
Machine Price: 8692 yuan
Accessories name brand Model reference price (yuan)
Processor: Intel Core i7 4770¥1980
Radiator: Owl nh-d14¥599
Motherboard: Gigabyte ga-z87m-hd3¥999
RAM: Kingston DDR3 1600 8G single ¥440
HDD: Seagate Barracuda 2TB 6
about One-third to One-second of the heap size, but this is not a guideline, after all, it depends on the application logic. It is therefore better to investigate the rate of metamorphosis and the size of older generations of young generation to older generations, based on this (to ensure that older generations are too small to frequently promote GC-led memory o
continuous, so the distribution will be very fast; Likewise, the Eden area is recovering very quickly (because in most cases the Eden object survives a very short period of time, and the Eden area uses a replication recovery algorithm that is very efficient in the case of a small number of surviving objects, described later in detail).
If you do not have enough memory allocations or extensions after the garbage collection has been performed, you will throw a Outofmemoryerror:java Heap space exc
collection.
The little one needs more tests.
Python divides all objects into three generations of 0,1,2. All new objects are 0-generation objects. When a generation of objects experiences garbage collection and survives, it is classified as a next-generation object. When garbage collection starts, all 0 generations of objects are scanned. If the 0 generation is garbage collected for a certain number of
generation size.Increasing the number of young generations will reduce the size of the older generation, which has a greater impact on system performance, Sun officially recommended configuration for the entire heap of 3/8
-xx:newsize
Set young generation size (for 1.3/1.4)
Set Young generation size
-xx:maxnewsize
Set the young generation maximum (for 1.3/1.4)
Set maximum young generation size
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.