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

29
LINES

< > BotCompany Repo | #1024216 // Heap dump once on too much memory use

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 6315K of libraries. Click here for Pure Java version (4980L/25K).

1  
!7
2  
3  
set flag OshiNotSticky.
4  
5  
cmodule EmergencyHeapDump > DynEnabled {
6  
  transient SimpleLiveValue<S> lvStatus = stringLiveValue();
7  
  switchable int max = 1024;
8  
  
9  
  visual centerAndSouthWithMargins(jCenteredLiveValueLabel(lvStatus), super);
10  
11  
  start {
12  
    lvStatus.set("Current threshold: " + max + " GB. You have 60s to change this value in this module's menu.");
13  
    doEvery(60.0, 30.0, r checkIt); // allow 60 seconds after start to change max value
14  
  }
15  
  
16  
  long usedMegabytes() {
17  
    ret oshi_currentProcessResidentSize()/oneMegabyte();
18  
  }
19  
  
20  
  void checkIt enter {
21  
    long megabytes = usedMegabytes();
22  
    lvStatus.set("Automatic heap dump " + (enabled ? "enabled" : "disabled") + ". Memory use: " + megabytes + "/" + max + " MB");
23  
    if (!enabled) ret;
24  
    if (megabytes >= max) {
25  
      setEnabled(false);
26  
      stefansOS_dumpHeap();
27  
    }
28  
  }
29  
}

Author comment

Began life as a copy of #1016395

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024216
Snippet name: Heap dump once on too much memory use
Eternal ID of this version: #1024216/4
Text MD5: ec3a6b57dfcabf02f4938cace644d780
Transpilation MD5: 40db999ee145daddb80dfaec84da8551
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-26 15:57:40
Source code size: 883 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 1486
Version history: 3 change(s)
Referenced in: [show references]