---
title: "Eclipse GC log"
author: "bd2007"
date: "2012-02-04T16:59:22Z"
tags: []
slug: "eclipse-gc-log"
draft: false
lastmod: "2012-02-04T16:59:22Z"
id: 1393487
url: "https://bd2007.iteye.com/blog/1393487"
---

为了查看Eclipse GC log，需要在eclipse.ini 中加入

?

?


```html
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
-verbose:gc
-Xloggc:gc.log
```

?

?

在Eclipse安装目录查看gc.log

?

9.768:  9172K->9025K(39616K), , 0.3122537 secs]

?

从上面的日志看似有perm 区(16384K)满引起的Full GC, 需要增大perm区空间和初始空间

?

?


```html
-XX:PermSize=64m
-XX:MaxPermSize=64m
```

?

?在重启Eclipse有如下log

?

?

1.338:  10944K->1028K(39616K), 0.0224436 secs] ?

2.053:  11972K->1431K(39616K), 0.0161071 secs] ?

2.923:  12375K->2044K(39616K), 0.0193916 secs]

?

?

貌似初始yong 区空间小了引起yong GC，让初始堆空间跟最大堆空间一样大（yong区应该也会按比例增大吧），GC消除了。

?

最终eclipse.ini如下

?

?


```html
-startup
plugins/org.eclipse.equinox.launcher_1.1.1.R36x_v20101122_1400.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.2.R36x_v20101222
-product
org.eclipse.epp.package.java.product
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms384m
-Xmx384m
-XX:PermSize=64m
-XX:MaxPermSize=64m
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
-verbose:gc
-Xloggc:gc.log

```

?

?

?

有趣的是关掉Eclipse会看到如下的log

?

?

20.639:  104960K->12258K(380160K), 0.2110277 secs] ?

31.909:  117218K->19392K(380160K), 0.2578431 secs] ?

Heap

?def new generation ? total 118016K, used 37344K [0x02b00000, 0x0ab00000, 0x0ab00000)

? eden space 104960K, ?28% used [0x02b00000, 0x0484a4c0, 0x09180000)

? from space 13056K, ?56% used [0x09180000, 0x098add90, 0x09e40000)

? to ? space 13056K, ? 0% used [0x09e40000, 0x09e40000, 0x0ab00000)

?tenured generation ? total 262144K, used 12041K [0x0ab00000, 0x1ab00000, 0x1ab00000)

? ?the space 262144K, ? 4% used [0x0ab00000, 0x0b6c25c0, 0x0b6c2600, 0x1ab00000)

?compacting perm gen ?total 65536K, used 36982K [0x1ab00000, 0x1eb00000, 0x1eb00000)

? ?the space 65536K, ?56% used [0x1ab00000, 0x1cf1d8e0, 0x1cf1da00, 0x1eb00000)

No shared spaces configured.

<div><br>
<div><br>
<div>1：是什么触发了yong GC？关Eclipse时需要创建对象引起GC释放更多的对象？
<div>2： Yong 区空间118016K + tenured 空间262144K = 380160K, 这约等于我们Xms/Xmx设置的空间。所以xms/xmx大小不包括perm区空间
<div><br>
?