The moose likes Java in General and the fly likes size of object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "size of object" Watch "size of object" New topic
Author

size of object

Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 625

Suppose I have a java class(TabsAsset) with 20 fields. Then what could be the size of object when I initialize the object.
TabsAsset ta = new TabsAsset();
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

Formally, it's implementation-dependent, and invisible from Java. Practically, assume 32 bits for each member, plus a 32-bit pointer to the class record, and that will certainly be in the right ballpark.


[Jess in Action][AskingGoodQuestions]
Hung Yee
Greenhorn

Joined: Dec 22, 2004
Posts: 18
JavaWorld has an article on this topic that might interest you:
http://www.javaworld.com/javaworld/javaqa/2003-12/02-qa-1226-sizeof.html
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: size of object
 
Similar Threads
How can I increase the size of a Font?
What is in the Session?
object size
To Herbert Schildt
type conversion