There is no easy answer because there is no "sizeof" operator in Java. Java stores extra run-time type information (RTTI) with each object, so it's not just a case of adding up the number of characters in each string. Martin
Avais Aziz
Greenhorn
Joined: Oct 07, 2001
Posts: 16
posted
0
Thanks! Martin But it is still not clear to me ( I am just a beginner ). So is there any way I can get the memory size even it is difficult to get it. Thanks Avais
Originally posted by Martin Rennix: There is no easy answer because there is no "sizeof" operator in Java. Java stores extra run-time type information (RTTI) with each object, so it's not just a case of adding up the number of characters in each string. Martin
Martin Rennix
Ranch Hand
Joined: Sep 30, 2001
Posts: 34
posted
0
Not that I know of! The amount of memory used is platform specific - remember Java is designed to be hardware independent. Martin
"JavaRanch, where the deer and the Certified play" - David O'Meara
Martin Rennix
Ranch Hand
Joined: Sep 30, 2001
Posts: 34
posted
0
Well, as an old-hand C programmer I liked knowing how much memory my structures took up! Maybe Sun were worried that people would find out the real memory footprint of each object! Just a thought. Cindy, surely your opinion is purely subjective - we should never assume that a programmer will never need to do something.
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
The intent was that lots of C/C++ programmers have it so drilled into their heads that THEY have to control memory management, that they try to FORCE Java to do the same dance for no real good reason at all, just that they can't let go. So if this person has a REAL reason for needing to know this, I would be interested in hearing it - but I am skeptical.
Avais Aziz
Greenhorn
Joined: Oct 07, 2001
Posts: 16
posted
0
Hi! Cindy and Martin Thanks for your replies. I am not a programmer of any language so far. So I am really new in your world. And I want to move ahead with solid foundation. This topic was not clear to me so I thought to disscuss not just ask. I have visited this forum a few times before and I think people here are very freindly and helpful. That's why I asked again. Avais
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
The correct "Java oriented" answer is - don't worry about it too much. The array itself will not be that big, because it is just going to hold the object meta-data plus the references to the 3 Strings and their indexes. The Strings themselves will be held elsewhere.