Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to get the Object size at runtime ?

Posted on 2009-07-14
5
Medium Priority
?
677 Views
Last Modified: 2012-05-07
We want to find out Object size at runtime
But
Do not want to use Reflection, because it adds performance issue.
Do not want to use the conventional method of calculating an Object by the no. of Primitive data it holds.

Is there any other way, i can get the Object size but that does not add any performance issue.
0
Comment
Question by:manojatinfy
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 24847528
There's certainly no overhead-free way of doing it. Just check memory usage via Runtime before and after creation
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 24847545
You can't get the size of the object at runtime in java. You
can only guess, which I don't think you are asking.
0
 
LVL 20

Expert Comment

by:a_b
ID: 24847602
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 24847692
0
 

Author Comment

by:manojatinfy
ID: 24901941
Dear Objects,
While running the sizeOf program, we are getting following error.
Exception in thread "main" java.lang.IllegalStateException: Instrumentation is null
      at net.sourceforge.sizeof.SizeOf.sizeOf(SizeOf.java:59)
Kindly suggest, if there are any inputs required.
Can you please share the Help text to run this program.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question