How to get the Object size at runtime ?

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.
manojatinfyAsked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
0
 
CEHJCommented:
There's certainly no overhead-free way of doing it. Just check memory usage via Runtime before and after creation
0
 
Ajay-SinghCommented:
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
 
a_bCommented:
0
 
manojatinfyAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.