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

28
LINES

< > BotCompany Repo | #1006268 // jMemoryView - a little view that shows the memory used in this VM

JavaX fragment (include)

sbool jMemoryView_debug;

static JLabel jMemoryView() {
  final JLabel l = jlabel(); 
  installTimer(l, 500, new Runnable {
    long compilationTime;
    public void run {
      //l.setText("T: " + toM(totalMemory()) + "M");
      //l.setToolTipText("T = Total Java heap. Process ID: " + getPID());
      l.setText(toM(usedMemory()) + "/" + toM(totalMemory()) + "M");
      S toolTip = "RAM used/total. Process ID: " + getPID();
      
      long t = hotSpotCompilationTime();
      bool compiling = t >= compilationTime + 500/10;
      float ratio = (t-compilationTime)/500f;
      compilationTime = t;
      if (compiling)
        toolTip += ". OPTIMIZING";
      //l.setForeground(compiling ? Color.green : Color.black);
      Color color = blendColors(Color.black, Color.green, ratio);
      l.setForeground(color);
      if (jMemoryView_debug) print("jMemoryView ratio: " + ratio + ", color: " + color);
      l.setToolTipText(toolTip);
    }
  });
  onLeftClick(l, r { fullGCInBackground() });
  ret l;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006268
Snippet name: jMemoryView - a little view that shows the memory used in this VM
Eternal ID of this version: #1006268/10
Text MD5: 27d6fa069e66281c04d3a9a40b1b522d
Author: stefan
Category: javax / ocr
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-24 13:09:16
Source code size: 1037 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 563 / 542
Version history: 9 change(s)
Referenced in: [show references]