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).

!7

set flag OshiNotSticky.

cmodule EmergencyHeapDump > DynEnabled {
  transient SimpleLiveValue<S> lvStatus = stringLiveValue();
  switchable int max = 1024;
  
  visual centerAndSouthWithMargins(jCenteredLiveValueLabel(lvStatus), super);

  start {
    lvStatus.set("Current threshold: " + max + " GB. You have 60s to change this value in this module's menu.");
    doEvery(60.0, 30.0, r checkIt); // allow 60 seconds after start to change max value
  }
  
  long usedMegabytes() {
    ret oshi_currentProcessResidentSize()/oneMegabyte();
  }
  
  void checkIt enter {
    long megabytes = usedMegabytes();
    lvStatus.set("Automatic heap dump " + (enabled ? "enabled" : "disabled") + ". Memory use: " + megabytes + "/" + max + " MB");
    if (!enabled) ret;
    if (megabytes >= max) {
      setEnabled(false);
      stefansOS_dumpHeap();
    }
  }
}

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: 149 / 1477
Version history: 3 change(s)
Referenced in: [show references]