top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to find out how much memory is used by an object in Java?

+2 votes
63 views

Java does not have sizeof operator now my question is How to find out how much memory is used by an object in Java?

posted Apr 15, 2016 by Madhavi Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

You can use the java.lang.instrumentation package.Here is details of this package:
http://docs.oracle.com/javase/7/docs/api/java/lang/instrument/Instrumentation.html

It has a method that can be used to get the implementation specific approximation of object size, as well as overhead associated with the object and follow this link to get a suitable program for your requirement.

http://stackoverflow.com/questions/9368764/calculate-size-of-object-in-java

answer Apr 16, 2016 by Shivam Kumar Pandey
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...