aspose file tools*
The moose likes Java in General and the fly likes Size of the Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Size of the Object" Watch "Size of the Object" New topic
Author

Size of the Object

Dharmendra Kumar
Greenhorn

Joined: May 03, 2002
Posts: 5
Can anybody help me to find the size of the object in Java. Is there any methods to find this.
Thanks
Dharam
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
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.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Doanh Nguyen
Ranch Hand

Joined: Dec 02, 2000
Posts: 45
I would write it to a temporary file, then use the File length() method.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
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

Joined: May 03, 2002
Posts: 5
Hi all
Thanks for the information and the links provided.
Thanks
Dharmendra
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Size of the Object