G1GC - Tenured如何在没有混合GC的情况下进行清洁(G1GC - How can Tenured get cleaned without a mixed GC)
我已经创建了一个测试Java程序来帮助理解G1GC的工作原理。
我的程序有两个线程 - 一个加载一个大型的ArrayList,大约200MB的对象(只有1000个字符串),然后它删除一个元素,并在一个循环中添加一个元素,其中有一个sleep。 这里的想法是让它慢慢老化并最终落入Tenured。
另一个线程只是在while循环中创建一个大字符串来创建大量垃圾以导致GC运行。
这一切似乎都运作正常,但我感到困惑的是,终身的浪费似乎得到清理,没有混合的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发生,终身空间如何得到清理?
I have created a test Java program to help understand how the G1GC works.
My program has two threads - one loads a large ArrayList with about 200MB of objects (just 1000 character strings) and then it removes an element and adds an element in a loop with a sleep in it. The idea here it to have something that ages slowly and will end up in Tenured.
The other thread just creates a large string in a while loop to create lots of garbage to cause GC runs.
This all seems to work OK, but what I am confused about is that the waste in tenured seems to get cleaned with no mixed GCs running.
[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)]
This is a snippet of the GC log. Note that between this run:
[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)]
So the usage in Tenured seems to have shrank on this run. However, there is no mention of a mixed GC, infact all it gives is:
[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 %]
So my question is - how is the tenured space getting cleaned without a mixed (or a full) GC happening?
原文:https://stackoverflow.com/questions/46473178
最满意答案
如果您需要更改每个所选节点的图标,Adnan Y的答案将起作用(只需确保
data.action
为"select_node"
):$("#jstree2").on('changed.jstree', function(evt, data) { if(data.action === "select_node") { data.instance.set_icon(data.node, 'http://jstree.com/tree-icon.png'); } });
如果您需要对节点打开和关闭做出反应,请使用类似的代码:
$("#jstree2") .on('open_node.jstree', function(evt, data) { data.instance.set_icon(data.node, 'http://jstree.com/tree-icon.png'); }) .on('close_node.jstree', function(evt, data) { data.instance.set_icon(data.node, true); });
在第二个示例中,图标设置为
true
- 这会将其恢复为默认图标(如果这是您需要的)。If you need to change the icon of each selected node, the answer by Adnan Y will work (just make sure
data.action
is"select_node"
):$("#jstree2").on('changed.jstree', function(evt, data) { if(data.action === "select_node") { data.instance.set_icon(data.node, 'http://jstree.com/tree-icon.png'); } });
If you need to react on nodes opening and closing, use similar code:
$("#jstree2") .on('open_node.jstree', function(evt, data) { data.instance.set_icon(data.node, 'http://jstree.com/tree-icon.png'); }) .on('close_node.jstree', function(evt, data) { data.instance.set_icon(data.node, true); });
In the second example the icon is set to
true
- this will restore it to the default icon (if this is what you need).
相关问答
更多-
最后,我能够通过在css中更改背景位置来渲染图像。 这里是我找到用于从精灵渲染图像的CSS代码的工具。 雪碧牛 打开你的图像并选择部分。 之后,我创建了独立的类并使用了后台位置css。 .jstree-folder-open { background-image: url('32px.png') !important; background-position: -105px -70px !important; } .jstree-folder-closed { background-image: url( ...
-
如果你没有使用复选框,并且你唯一的预订是彼此依赖,请尝试使用复选框插件但将“three_state”设置为false。 来自JSTree : $ .jstree.defaults.checkbox.three_state:一个布尔值,指示复选框是否应该级联并具有未确定状态。 默认为true。 If you're ok with using checkboxes and your only reservation is the dependence on one another, try using the ...
-
只需在容器上方添加一个div,如下所示:
单击jstree上的更改图标(Change icon on click jstree)[2023-06-13]
如果您需要更改每个所选节点的图标,Adnan Y的答案将起作用(只需确保data.action为"select_node" ): $("#jstree2").on('changed.jstree', function(evt, data) { if(data.action === "select_node") { data.instance.set_icon(data.node, 'http://jstree.com/tree-icon.png'); } }); 如果您需要对节点打开和关闭 ...jsTree加载并单击(jsTree load and click)[2023-02-26]
如果要获取节点的完整路径,可以使用get_path // The true means it will return the ID's of the parent, therefore ALL NODES need an ID var parents = $("#your_jstree").jstree("get_path",$("#the_node"),true); $.each(parents, function(k, v){ // Log down the ID's console. ...查看api,您可以使用move_node。 它似乎需要父模式,因此对于您的示例,我添加了一个id =“root0”的整体根节点。 然后点击按钮: $('#tree').jstree("move_node", "#b", "#root0", 0); 这表示取名为“b”的节点,将其移动到名为“root0”的父节点并将其置于“0”位置。 更新了FIDDLE Looking at the api, you can use move_node. It seems to require a parent mode, ...jsTree图标没有出现(jsTree icons not appearing)[2022-04-06]
我相信你使用的是旧版本的jsTree。 我建议获取最新版本并使代码适应新的语法。 我设法通过遵循它的文档很快地使它工作。 以下是工作示例: http : //jsfiddle.net/bortao/SJgLJ/ 您需要更改类型定义: JS 'types': { 'Tasks': { 'icon': 'iconfile.png' } } HTML黄瓜和jstree(Cucumber and jstree)[2022-01-07]
您可以使用jstree的方法与树进行交互 - 为此,您需要在节点上设置id,因此可以通过jstree引用它们。 jQuery的 // toggle_node, or open_node, or close_node $('#tree').jstree('toggle_node', '#node_b'); 小提琴: http : //jsfiddle.net/aV62w/1/ You can interact with the tree by utilising jstree's methods -- fo ...这不是理想的解决方案,但您可以这样做: $('#tree_2').jstree({..}) .bind('click.jstree', function (e, datap) { treeClicked(e, datap); }).bind('select_node.jstree', function (e, datap) { treeClicked(e, datap); }); function treeClicked(e, datap) { alert("tree click ...你有没有检查过你的函数范围内是否可以访问this.href? 很可能你引用的是jquery而不是对象本身 尝试: var self = this; $('.myClass').click(function(){ return false; }).dblclick(function() { window.location = this.href; return false; }); I gave up on using an anchor and just used a double ...相关文章
更多- Ehcache BigMemory: 摆脱GC困扰
- 在Twitter,Netty 4 GC开销降为五分之一
- 谷歌G1叫板iPhone
- Becoming a data scientist
- She’s Not Carrying A Handbag
- ServletOutputStream cannot be resolved to a type
- Create a Bootable MicroSD Card
- Drupal Forums instead of phpBB or vBulletin: A casestudy
- Stack Overflow Architecture Update - Now At 95 Million Page Views A Month
- [译文] 恶意软件行为综述 - A View on Current Malware Behaviors
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。