I need to know that how can i determine the actual size occupied by an object in memory.Either via any method specified in Java API or any implementation by JVM.
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
They were just talking about an objects size in Beginner yesterday. You might try using the search link at under the two buttons above. There have been LOTS of conversations on this topic in Beginner as well as Intermediate.
"JavaRanch, where the deer and the Certified play" - David O'Meara
Thomas Smets
Ranch Hand
Joined: Dec 11, 2001
Posts: 111
posted
0
Have you already tried to simply look at the long freeMemory() or long totalMemory() &see how you could use these ? Say doing smthg like :
Running the program gives :
Memory used is : 1130416 Average size is : 11 bytes Press any key to continue...
Changing the line to
Ten times more objects gives :
Memory used is : -4076792 Average size is : -4 bytes Press any key to continue...