1 | import javax.management.*; |
2 | import javax.management.openmbean.CompositeData; |
3 | import com.sun.management.GcInfo; |
4 | import com.sun.management.GarbageCollectionNotificationInfo; |
5 | |
6 | sclass GCPause { |
7 | long start, duration; |
8 | S name, cause, action; |
9 | |
10 | toString { |
11 | ret "GCPause duration=" + duration + " ms, start=" + start + " (VM time). " + renderStructs(+name, +cause, +action); |
12 | } |
13 | } |
14 | |
15 | static new Flag collectGCPauses_started; |
16 | static L<GCPause> collectGCPauses_list; |
17 | |
18 | static void collectGCPauses() { |
19 | collectGCPauses(1000); |
20 | } |
21 | |
22 | static void collectGCPauses(int bufferSize) { |
23 | if (!collectGCPauses_started.raise()) ret; |
24 | collectGCPauses_list = synchroList(LatestList(bufferSize)); |
25 | |
26 | onGCNotification(voidfunc(GarbageCollectionNotificationInfo info) { |
27 | GcInfo gcInfo = info.getGcInfo(); |
28 | GCPause pause = nu(GCPause, |
29 | start := gcInfo.getStartTime(), |
30 | duration := gcInfo.getDuration(), |
31 | name := info.getGcName(), |
32 | cause := info.getGcCause(), |
33 | action := info.getGcAction()); |
34 | collectGCPauses_list.add(pause); |
35 | }); |
36 | } |
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: | 456 / 465 |
Version history: | 2 change(s) |
Referenced in: | [show references] |