Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1007491 // dumpHeap - dump heap to a file readable by jhat [HotSpot version]

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3991L/27K).

// Note: On OpenJ9, the class HotSpotDiagnosticMXBean does not seem to exist.

import javax.management.MBeanServer;
import java.lang.management.ManagementFactory;

static void dumpHeap(File file) ctex {
  MBeanServer server = ManagementFactory.getPlatformMBeanServer();
  virtual HotSpotDiagnosticMXBean bean = 
    ManagementFactory.newPlatformMXBeanProxy(server,
    "com.sun.management:type=HotSpotDiagnostic", classForName("com.sun.management.HotSpotDiagnosticMXBean"));
  file.delete();
  mkdirsForFile(file);
  temp tempInfoBoxForever("Dumping heap...");
  long time = sysNow();
  call(bean, 'dumpHeap, f2s(file), true);
  done2_always(time, "Done. " + fileInfo(file));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007491
Snippet name: dumpHeap - dump heap to a file readable by jhat [HotSpot version]
Eternal ID of this version: #1007491/12
Text MD5: 58d52204e35583144df432eb910ab5ff
Transpilation MD5: 4aca309870c35aac62ddeacc6afebd62
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-26 23:17:23
Source code size: 695 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 619 / 683
Version history: 11 change(s)
Referenced in: [show references]