• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Size of the Object

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody help me to find the size of the object in Java. Is there any methods to find this.
Thanks
Dharam
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Dharam:
Can anybody help me to find the size of the object in Java. Is there any methods to find this.
Thanks
Dharam


i have seen the ans of this question at Sun's site in one of the qow. because of the fact i am very poor in writing so i can't explaint that here.just go there and find that qow.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dharam,

Please change your name to be compliant with JavaRanch's naming policy.
Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name.
Thanks,
Cindy
Also, if you use the search function you will find lots of references to this topic.
For instance there was a good conversation here.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would write it to a temporary file, then use the File length() method.
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doanh
Your method can do the estimation, but not accurate. There is no way to accurately measure the size of object in Java as C sizeof() method. I guess that is intentional to hide some poor memory management problem in Java. Another thing is different JVM can have different implementation as well as different sizes.
Read here to know a little more, a little old, but still useful:
The Java IAQ:Infrequently Answered Questions
Need Java real project experience? Join our project team here!
 
Dharmendra Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
Thanks for the information and the links provided.
Thanks
Dharmendra
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic