Java garbage collector's serial old collector

Source: Internet
Author: User

Serial Oldcollectors areJAVAone of the garbage collectors in a virtual machine,itis aSerialThe old-age version of the collector, which is also a single-threaded collector, uses the "tag-collation "algorithm. This collector is also mainly in the currentJAVAof theClientvirtual machines in the mode of use. If theServermode, it has two major uses: one is inJDK 1.5and previous versions of theParallel Scavengecollectors, and the other one is to use asCMSA backup plan for the collector. IfCMSCollector appearsConcurrent Mode Failure, youSerial OldThe Collector will act as a fallback collector.

1 , simple example

Source

Package COM.GC;

Import java.util.ArrayList;

Import java.util.List;

/**

 * simple. JAVA Virtual machine Memory Reclamation , serial old Use of Collectors

 * Parameters: -xms30m-xmx100m-xmn10m-xx:+useserialgc-xx:+printgcdetails

* @author Fan Fangming

*/

public class Easyserialold {

Public byte[] PlaceHolder =new byte[64 * 1024x768];// placeholder

public static Voidmain (string[] args) throws exception{

Outofmemorybyexpansionsize ();

}

private static Voidoutofmemorybyexpansionsize () throws exception{

List<easyserialold>list = new arraylist<easyserialold> ();

while (true) {

easyserialoldserial = new Easyserialold ();

List.add (serial);

Thread.Sleep (Ten);// Pause Ten milliseconds

}

}

}

Parameters

-xms30m JVM Minimum 30M

-xmx100m JVM Maximum 100M

-xmn10m Cenozoic Fixed 10M

-XX:+USESERIALGC corresponding serial + serial old Collecting Device

-xx:+printgcdetails Print Details GC

Run results

[GC [defnew:8137k->1023k (9216K), 0.0070798 secs] 8137k->8019k (29696K), 0.0071114 secs] [times:user=0.00sys=0.00, real=0.01 secs]

[GC [Defnew:9175k->963k (9216K), 0.0056184 secs] 16170k->16151k (29696K), 0.0056422 secs] [times:user=0.00sys=0.00, real=0.00 secs]

[GC [defnew:9149k->964k (9216K), 0.0050408 secs][tenured:23320k->23388k (23424K), 0.0030744 secs]24337k-> 24284K (32640K), [perm:2086k->2086k (12288K)], 0.0082092 secs][times:user=0.00 sys=0.00, real=0.01 secs]

[GC [defnew:8166k->964k (9216K), 0.0052883 secs] 31555k->31522k (48200K), 0.0053220 secs] [times:user=0.00sys=0.00, real=0.01 secs]

[GC [Defnew:9118k->962k (9216K), 0.0050018 secs] 39676k->39654k (48200K), 0.0050367 secs] [times:user=0.00sys=0.02, real=0.00 secs]

[GC [defnew:9108k->966k (9216K), 0.0049332 secs][tenured:46824k->46893k (46920K), 0.0033687 secs]47800k-> 47790K (56136K), [perm:2086k->2086k (12288K)], 0.0084489 secs][times:user=0.02 sys=0.00, real=0.01 secs]

[GC [Defnew:8141k->963k (9216K), 0.0056947 secs] 55034k->55026k (87372K), 0.0057206 secs] [times:user=0.00sys=0.00, real=0.01 secs]

[GC [Defnew:9099k->962k (9216K), 0.0046619 secs] 63162k->63158k (87372K), 0.0046951 secs] [times:user=0.00sys=0.00, real=0.00 secs]

[GC [defnew:9102k->968k (9216K), 0.0048499 secs] 71298k->71296k (87372K), 0.0048757 secs] [times:user=0.00sys=0.00, real=0.00 secs]

[GC [Defnew:9104k->962k (9216K), 0.0053368 secs][tenured:78465k->78531k (78540K), 0.0035892 secs]79431k-> 79427K (87756K), [perm:2086k->2086k (12288K)], 0.0090187 secs][times:user=0.00 sys=0.00, real=0.01 secs]

[GC [Defnew:8134k->962k (9216K), 0.0061709 secs] 86665k->86663k (101376K), 0.0061952 secs] [times:user=0.00sys=0.00, real=0.01 secs]

[GC [defnew:9096k->9096k (9216K), 0.0000242 secs][tenured:85701k->92157k (92160K), 0.0230609 secs]94797k-> 94783K (101376K), [perm:2086k->2084k (12288K)], 0.0231402 secs][times:user=0.03 sys=0.00, real=0.02 secs]

[Full GC [tenured:92157k->92157k (92160K), 0.0044209 secs] 101264k->101260k (101376K), [perm:2084k->2084k ( 12288K)], 0.0044763 secs] [times:user=0.00 sys=0.00,real=0.00 secs]

[Full GC [tenured:92157k->92151k (92160K), 0.0072855 secs] 101260k->101254k (101376K), [perm:2084k->2084k ( 12288K)], 0.0073138 secs] [times:user=0.00 sys=0.00,real=0.01 secs]

Exception in thread "main" Java.lang.OutOfMemoryError:Java heap space

atcom.gc.easyparnew.<init> (easyparnew.java:12)

atcom.gc.EasyParNew.outOfMemoryByExpansionSize (easyparnew.java:39)

Atcom.gc.EasyParNew.main (easyparnew.java:14)

Heap

def New Generation Total 9216K, used 9152K [0x03b70000,0x04570000, 0x04570000)

Eden Space 8192K, 100% used [0x03b70000, 0x04370000, 0x04370000)

From Space 1024K, 93% used[0x04470000, 0x045600f0, 0x04570000)

To space 1024K, 0% used [0x04370000, 0x04370000, 0x04470000)

Tenured generation total 92160K, used 92151K [0x04570000,0x09f70000, 0x09f70000)

The space 92160K, 99% used[0x04570000, 0x09f6de68, 0x09f6e000, 0x09f70000)

Compacting Perm Gen Total 12288K, used 2105K [0x09f70000,0x0ab70000, 0x0df70000)

Results analysis

[GC [defnew:9149k->964k (9216K), 0.0050408 secs][tenured:23320k->23388k (23424K), 0.0030744 secs]24337k-> 24284K (32640K), [perm:2086k->2086k (12288K)], 0.0082092 secs][times:user=0.00 sys=0.00, real=0.01 secs]

tenured:23320k->23388k (23424K), the old age in recycling garbage (this code used to do memory overflow is the ace ... ), the space is gone, but the JVM is divided by a maximum of 100M and can continue to allocate space. And then came the second time:

[GC [Defnew:9104k->962k (9216K), 0.0053368 secs][tenured:78465k->78531k (78540K), 0.0035892 secs]79431k-> 79427K (87756K), [perm:2086k->2086k (12288K)], 0.0090187 secs][times:user=0.00 sys=0.00, real=0.01 secs]

tenured:78465k->78531k (78540K), the old age space has become significantly larger ... Soon, 100M space is running out.

with [Full gc[tenured:92157k->92157k (92160K), 0.0044209 secs] 101264k->101260k (101376K), [perm:2084k->2084k ( 12288K], 0.0044763 secs] [times:user=0.00 sys=0.00,real=0.00 secs] For a strong recovery, and no use, so hang up ...

Java garbage collector's serial old collector

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.