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

23
LINES

< > BotCompany Repo | #1018913 // Measure memory size of object array

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (7959L/45K).

!7

sclass LenOnly {
  int len;
}

sclass LenPlusClass {
  int len;
  Class c;
}

p {
  print(+isCompressedOOPS());
  int n = 8*oneMegabyte_int();
  
  for (int l = 0; l <= 8; l++) {
    final int _l = l;
    print("new O[" + l + "] => " + exclusive_measureSizeOfObject(n, -> new O[_l]));
  }
  print("LenOnly=" + exclusive_measureSizeOfObject(n, -> new LenOnly));
  print("LenOnly/unsafe=" + unsafe_sizeOf(new LenOnly));
  print("LenPlusClass=" + exclusive_measureSizeOfObject(n, -> new LenPlusClass));
}

Author comment

Began life as a copy of #1017100

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018913
Snippet name: Measure memory size of object array
Eternal ID of this version: #1018913/12
Text MD5: 49e2f2ac99dca1d12b30f5d1cdea7c34
Transpilation MD5: f62a9c730e56afa38331f8037034f268
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-11 18:51:21
Source code size: 527 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 455
Version history: 11 change(s)
Referenced in: [show references]