Size of object in java : Is there any way in java to find of size of an object ?( like sizeof() operator of C/C++ )

Showing Answers 1 - 3 of 3 Answers

nakt

  • Nov 18th, 2005
 

You can check Runtime r = Runtime.getRuntime() ;r.freeMemory() ;before and after the creation of the new Object you can check the memorty and by subtraction u can get the used memory. Not accurate but useful.

  Was this answer useful?  Yes

Sander

  • Mar 20th, 2006
 

Using ObjectStream to read object and count size.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions