• Post Reply Bookmark Topic Watch Topic
  • New Topic

size of object  RSS feed

 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.....
Is there a way to find out the size of the object of given type?
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, and you will find similar posts with more answers in, if you search these fora.

But knowing the memory size or location is inconsistent with the concepts of a high-level language. Let the JVM worry about that sort of details. Otherwise it is like saying, "If I drive this car I really must know whether it has a 4-cylinder engine or a 6-cylinder engine."
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further, the size of the object can be dependent on the particular JVM. So you can run your bytecode on a Windows box and the object will be X bytes, and the same bytecode on Linux will be Y bytes, where X may or may not be equal to Y.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!