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)

1  
sbool jMemoryView_debug;
2  
3  
static JLabel jMemoryView() {
4  
  final JLabel l = jlabel(); 
5  
  installTimer(l, 500, new Runnable {
6  
    long compilationTime;
7  
    public void run {
8  
      //l.setText("T: " + toM(totalMemory()) + "M");
9  
      //l.setToolTipText("T = Total Java heap. Process ID: " + getPID());
10  
      l.setText(toM(usedMemory()) + "/" + toM(totalMemory()) + "M");
11  
      S toolTip = "RAM used/total. Process ID: " + getPID();
12  
      
13  
      long t = hotSpotCompilationTime();
14  
      bool compiling = t >= compilationTime + 500/10;
15  
      float ratio = (t-compilationTime)/500f;
16  
      compilationTime = t;
17  
      if (compiling)
18  
        toolTip += ". OPTIMIZING";
19  
      //l.setForeground(compiling ? Color.green : Color.black);
20  
      Color color = blendColors(Color.black, Color.green, ratio);
21  
      l.setForeground(color);
22  
      if (jMemoryView_debug) print("jMemoryView ratio: " + ratio + ", color: " + color);
23  
      l.setToolTipText(toolTip);
24  
    }
25  
  });
26  
  onLeftClick(l, r { fullGCInBackground() });
27  
  ret l;
28  
}

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: 643 / 617
Version history: 9 change(s)
Referenced in: [show references]