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)

// activity: runnable/voidfunc()/func() -> O
// function result will be held during measurement
static long measureTotalObjectSize(O activity, S desc) {
  long mem1 = memoryUsedAfterGC();
  O result = callF(activity);
  long mem2 = memoryUsedAfterGC();
  long diff = mem2-mem1;
  print("Memory used" + (nempty(desc) ? " for " + desc : "") + ": " + toK(diff) + " K");
  ret diff;
}

static long measureTotalObjectSize(O activity) {
  ret measureTotalObjectSize(activity, shorten(str(activity), 40));
}

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