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

14
LINES

< > BotCompany Repo | #1011001 // measureTotalObjectSize - works if you're the only running thread in the VM

JavaX fragment (include)

1  
// activity: runnable/voidfunc()/func() -> O
2  
// function result will be held during measurement
3  
static long measureTotalObjectSize(O activity, S desc) {
4  
  long mem1 = memoryUsedAfterGC();
5  
  O result = callF(activity);
6  
  long mem2 = memoryUsedAfterGC();
7  
  long diff = mem2-mem1;
8  
  print("Memory used" + (nempty(desc) ? " for " + desc : "") + ": " + toK(diff) + " K");
9  
  ret diff;
10  
}
11  
12  
static long measureTotalObjectSize(O activity) {
13  
  ret measureTotalObjectSize(activity, shorten(str(activity), 40));
14  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1011001
Snippet name: measureTotalObjectSize - works if you're the only running thread in the VM
Eternal ID of this version: #1011001/4
Text MD5: b5d513f552f11d99f24d1b8f016c99fe
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-11 16:30:28
Source code size: 513 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 414 / 453
Version history: 3 change(s)
Referenced in: [show references]