import javax.management.*; import javax.management.openmbean.CompositeData; import com.sun.management.GcInfo; import com.sun.management.GarbageCollectionNotificationInfo; sclass GCPause { long start, duration; S name, cause, action; toString { ret "GCPause duration=" + duration + " ms, start=" + start + " (VM time). " + renderStructs(+name, +cause, +action); } } static new Flag collectGCPauses_started; static L<GCPause> collectGCPauses_list; static void collectGCPauses() { collectGCPauses(1000); } static void collectGCPauses(int bufferSize) { if (!collectGCPauses_started.raise()) ret; collectGCPauses_list = synchroList(LatestList(bufferSize)); onGCNotification(voidfunc(GarbageCollectionNotificationInfo info) { GcInfo gcInfo = info.getGcInfo(); GCPause pause = nu(GCPause, start := gcInfo.getStartTime(), duration := gcInfo.getDuration(), name := info.getGcName(), cause := info.getGcCause(), action := info.getGcAction()); collectGCPauses_list.add(pause); }); }
Began life as a copy of #1013400
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1013407 |
Snippet name: | collectGCPauses |
Eternal ID of this version: | #1013407/3 |
Text MD5: | 5591b0162d9447c54f6a26eda211d830 |
Author: | stefan |
Category: | javax / gc / monitoring |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-01-05 02:25:56 |
Source code size: | 1080 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 455 / 464 |
Version history: | 2 change(s) |
Referenced in: | [show references] |