- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个测试 Java 程序来帮助了解 G1GC 的工作原理。
我的程序有两个线程 - 一个线程加载一个包含大约 200MB 对象(仅 1000 个字符串)的大型 ArrayList,然后删除一个元素并在循环中添加一个元素,其中包含 sleep。这里的想法是让一些东西慢慢老化并最终获得终身教职。
另一个线程只是在 while 循环中创建一个大字符串,以创建大量垃圾以导致 GC 运行。
这一切似乎都工作正常,但令我困惑的是,tenured 中的浪费似乎在没有运行混合 GC 的情况下得到了清理。
[Eden: 581.0M(581.0M)->0.0B(573.0M) Survivors: 9216.0K->9216.0K Heap: 904.3M(1024.0M)->330.9M(1024.0M)]
[Times: user=0.03 sys=0.00, real=0.00 secs]
2017-09-28T16:22:14.889+0000: 2.415: 2017-09-28T16:22:14.889+0000[GC concurrent-root-region-scan-start]
: 2.415: Total time for which application threads were stopped: 0.0081917 seconds, Stopping threads took: 0.0000852 seconds
2017-09-28T16:22:14.889+0000: 2.415: [GC concurrent-root-region-scan-end, 0.0002779 secs]
2017-09-28T16:22:14.889+0000: 2.415: [GC concurrent-mark-start]
2017-09-28T16:22:14.904+0000: 2.430: [GC concurrent-mark-end, 0.0143310 secs]
2017-09-28T16:22:14.905+0000: 2.431: [GC remark 2017-09-28T16:22:14.905+0000: 2.431: [Finalize Marking, 0.0003653 secs] 2017-09-28T16:22:14.905+0000: 2.431: [GC ref-proc2017-09-28T16:22:14.905+0000: 2.431: [SoftReference, 0 refs, 0.0008964 secs]2017-09-28T16:22:14.906+0000: 2.432: [WeakReference, 0 refs, 0.0005380 secs]2017-09-28T16:22:14.907+0000: 2.433: [FinalReference, 2 refs, 0.0005460 secs]2017-09-28T16:22:14.907+0000: 2.434: [PhantomReference, 0 refs, 0 refs, 0.0010243 secs]2017-09-28T16:22:14.908+0000: 2.435: [JNI Weak Reference, 0.0000090 secs], 0.0034419 secs] 2017-09-28T16:22:14.909+0000: 2.435: [Unloading, 0.0008396 secs], 0.0057362 secs]
[Times: user=0.03 sys=0.00, real=0.01 secs]
2017-09-28T16:22:14.911+0000: 2.437: Total time for which application threads were stopped: 0.0069810 seconds, Stopping threads took: 0.0011536 seconds
2017-09-28T16:22:14.911+0000: 2.437: [GC cleanup 418M->302M(1024M), 0.0014100 secs]
[Times: user=0.00 sys=0.00, real=0.00 secs]
2017-09-28T16:22:14.912+0000: 2.438: Total time for which application threads were stopped: 0.0015190 seconds, Stopping threads took: 0.0000697 seconds
2017-09-28T16:22:14.912+0000: 2.438: [GC concurrent-cleanup-start]
2017-09-28T16:22:14.912+0000: 2.439: [GC concurrent-cleanup-end, 0.0000987 secs]
2017-09-28T16:22:14.987+0000: 2.513: [GC pause (G1 Evacuation Pause) (young) 2.513: [G1Ergonomics (CSet Construction) start choosing CSet, _pending_cards: 4816, predicted base time: 5.38 ms, remaining time: 44.62 ms, target pause time: 50.00 ms]
2.513: [G1Ergonomics (CSet Construction) add young regions to CSet, eden: 573 regions, survivors: 9 regions, predicted young region time: 3.54 ms]
2.513: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 573 regions, survivors: 9 regions, old: 0 regions, predicted pause time: 8.92 ms, target pause time: 50.00 ms]
2017-09-28T16:22:14.991+0000: 2.517: [SoftReference, 0 refs, 0.0010742 secs]2017-09-28T16:22:14.992+0000: 2.518: [WeakReference, 0 refs, 0.0006150 secs]2017-09-28T16:22:14.992+0000: 2.519: [FinalReference, 0 refs, 0.0004760 secs]2017-09-28T16:22:14.993+0000: 2.519: [PhantomReference, 0 refs, 0 refs, 0.0008707 secs]2017-09-28T16:22:14.994+0000: 2.520: [JNI Weak Reference, 0.0000094 secs] 2.521: [G1Ergonomics (Mixed GCs) do not start mixed GCs, reason: reclaimable percentage not over threshold, candidate old regions: 14 regions, reclaimable: 13071400 bytes (1.22 %), threshold: 5.00 %]
, 0.0077749 secs]
[Parallel Time: 3.6 ms, GC Workers: 16]
[GC Worker Start (ms): Min: 2513.1, Avg: 2513.6, Max: 2515.2, Diff: 2.1]
[Ext Root Scanning (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.1, Sum: 0.9]
[Update RS (ms): Min: 0.0, Avg: 0.4, Max: 1.1, Diff: 1.1, Sum: 6.3]
[Processed Buffers: Min: 0, Avg: 1.2, Max: 4, Diff: 4, Sum: 20]
[Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.1, Sum: 0.8]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
[Object Copy (ms): Min: 1.2, Avg: 2.3, Max: 2.9, Diff: 1.7, Sum: 36.9]
[Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 2.1]
[Termination Attempts: Min: 1, Avg: 1.1, Max: 2, Diff: 1, Sum: 18]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.1, Diff: 0.0, Sum: 0.3]
[GC Worker Total (ms): Min: 1.4, Avg: 3.0, Max: 3.5, Diff: 2.1, Sum: 47.3]
[GC Worker End (ms): Min: 2516.5, Avg: 2516.6, Max: 2516.6, Diff: 0.1]
[Code Root Fixup: 0.0 ms]
[Code Root Purge: 0.0 ms]
[Clear CT: 0.2 ms]
[Other: 4.0 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 3.4 ms]
[Ref Enq: 0.2 ms]
[Redirty Cards: 0.1 ms]
[Humongous Register: 0.0 ms]
[Humongous Reclaim: 0.0 ms]
[Free CSet: 0.2 ms]
[Eden: 573.0M(573.0M)->0.0B(607.0M) Survivors: 9216.0K->7168.0K Heap: 787.9M(1024.0M)->221.4M(1024.0M)]
这是 GC 日志的片段。请注意,在这次运行之间:
[Eden: 581.0M(581.0M)->0.0B(573.0M) Survivors: 9216.0K->9216.0K Heap: 904.3M(1024.0M)->330.9M(1024.0M)]
...
[Eden: 573.0M(573.0M)->0.0B(607.0M) Survivors: 9216.0K->7168.0K Heap: 787.9M(1024.0M)->221.4M(1024.0M)]
因此,在这次运行中,Tenured 中的使用率似乎有所下降。然而,没有提到混合GC,事实上它给出的只是:
[G1Ergonomics (Mixed GCs) do not start mixed GCs, reason: reclaimable percentage not over threshold, candidate old regions: 14 regions, reclaimable: 13071400 bytes (1.22 %), threshold: 5.00 %]
所以我的问题是 - 如何在不发生混合(或完整)GC 的情况下清理永久空间?
最佳答案
不需要混合集合来撤出已发现并发循环完全未引用的旧区域。
2017-09-28T16:22:14.911+0000: 2.437: [GC cleanup 418M->302M(1024M), 0.0014100 secs]
还有一些额外的日志记录标志,例如-XX:+G1PrintHeapRegions
,可用于跟踪此类清理。请参阅oracle blog关于 G1GC 日志的深入解释。
关于java - G1GC - Tenured 如何在没有混合 GC 的情况下得到清理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46473178/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!