Download Jar. Libraryless. Click here for Pure Java version (3148L/20K).
!7 import javax.management.*; import javax.management.openmbean.CompositeData; import com.sun.management.GarbageCollectionNotificationInfo; p { wordWrapConsole(); NotificationListener listener = new NotificationListener { @Override public void handleNotification(Notification notification, O handback) { print("type: " + notification.getType()); if (notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) { // extract garbage collection information from notification. GarbageCollectionNotificationInfo gcInfo = GarbageCollectionNotificationInfo.from((CompositeData) notification.getUserData()); //print("Cause: " + gcInfo.getGcCause(); pnlStruct(callAllMethodsInInterface(gcInfo, GarbageCollectionNotificationInfo.class); print(); } } }; // register our listener with all gc beans for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) ((NotificationEmitter) gcBean).addNotificationListener(listener, null, null); }
Began life as a copy of #1013393
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: | #1013395 |
Snippet name: | Test GarbageCollectorMXBean 3 (GC notifications, OK) |
Eternal ID of this version: | #1013395/7 |
Text MD5: | 6e9892bfcf15be5231339dc19d4995ab |
Transpilation MD5: | c0fcc53e7bb6e0de5ea2bba2fd5db30f |
Author: | stefan |
Category: | javax / gc / monitoring |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-07 16:45:03 |
Source code size: | 1100 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 485 / 1130 |
Version history: | 6 change(s) |
Referenced in: | #1013400 - Collect GC Pause Times |