Hello there, Kwow using the Runtime class I could get the total amount of memory and the used memory of the JVM. But is there any way to find out how many bytes does a specific object take in the memory. Thanks in Advance Jack
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
I'm not sure how to do that. Why in the world would you want to know such a thing? Surely there is something that you are trying to ACCOMPLISH with this question.
"JavaRanch, where the deer and the Certified play" - David O'Meara
jack nick
Ranch Hand
Joined: Jan 11, 2001
Posts: 96
posted
0
Hi Cindy, Know this sounds like an out of the way task to be doing, but was just messing around with one of my project just to see how much memory my application was taking, then I got about wondering how much each of my objects may be occupying, hence the question. Though not critical would be nice to figure out if this CAN be done. Thanks anyway cindy Jack
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
How about taking a before and after shot of the used memory?
sharad goswami
Ranch Hand
Joined: Jan 18, 2001
Posts: 51
posted
0
AM NOT SURE.BUT U CAN USE DECODE OF WRAPPER CLASSES ALSO READBYTE in of higher stream in case of file.
Stop The World I Want To Get Off.
Karthik Guru
Ranch Hand
Joined: Mar 06, 2001
Posts: 1209
posted
0
c'd be naive, but why not try serializing the object into a file and see how much space it occupies :-) w'd give you some idea? karthik.
jack nick
Ranch Hand
Joined: Jan 11, 2001
Posts: 96
posted
0
Hi there, Thanks for your suggestion. Basically I took a shot before and after the creation of the object and also tried serializing the object, both showed me approx the same some bytes up and down. Bye Jack
sharad goswami
Ranch Hand
Joined: Jan 18, 2001
Posts: 51
posted
0
here u are.use freememory() and totalmemory() methos of runtime.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.