Yes , this question is little bit vague and any serious programmer would laugh about it ! Although java does not tell about the sizes it assigns to the varibles ,i mean it can give more memory or less memory depending on the situation( that way it is abstracted !)i know that stuff! but what i am asking is ,is there any technique that i can know about the runtime variable size ? i want to find the addresses of the variables too ! This question does not want any answers like ,see java docs it does not provide those functionality you have asked , i want some kind of hack to do this kind of stuff!
Asked
Active
Viewed 69 times
-1
-
As far as I know, primitives have a fixed-size (if that's what you are refering to). For memory/address management you could use C++ – Christian Tapia Mar 19 '14 at 04:36
-
maybe I am not serious because I am not laughing ;-) – Leo Mar 19 '14 at 04:37
-
java does not provide fixed sizes :( – Vamsi Pavan Mahesh Mar 19 '14 at 04:38
-
easy dude ! , what i meant was java does not provide fixed size primitives ... some programmers may feel wierd @Christian – Vamsi Pavan Mahesh Mar 19 '14 at 04:39
-
@VamsiPavanMahesh what do you mean by that? Any source? I think they are size-fixed: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html – Christian Tapia Mar 19 '14 at 04:39
-
i don't think those are fixed size .. java will promote or demote size ,i have read in complete reference @Christian – Vamsi Pavan Mahesh Mar 19 '14 at 04:40
-
Just curious, why do you need (or want) to know the size? – andars Mar 19 '14 at 04:41
-
@VamsiPavanMahesh could you provide a link/source that supports what you are telling? – Christian Tapia Mar 19 '14 at 04:42
-
they want me to do a symbol table program @andars – Vamsi Pavan Mahesh Mar 19 '14 at 04:42
-
The JVM is open source. Just look at the source code. – mttdbrd Mar 19 '14 at 04:42
-
http://www.java-samples.com/showtutorial.php?tutorialid=260 @Christian – Vamsi Pavan Mahesh Mar 19 '14 at 04:43
-
why would i get a downvote ,where as my counterpart question gets 204 ups ! :( – Vamsi Pavan Mahesh Mar 19 '14 at 04:45
-
1Because you asked it when the other question already exists. – Aurand Mar 19 '14 at 04:45
1 Answers
-2
Well, There is no such direct way to get accurate size consumed by each object in JVM. Although you can you use JCONSOLE or other similar monitoring tool to get footprints of the objects dynamically. Again, this is more towards monitoring and performance tuning.
Thanks, Anil

Anil Patel
- 21
- 2
-
Incorrect. See java.lang.instrument.Instrumentation and various utility libraries build around it such as jamm. – Aurand Mar 19 '14 at 05:32
-
Well, that's approximate size only.. What I am referring is accurate size. – Anil Patel May 04 '17 at 02:24