Why is sizeof operator not in java ?

Hello friends..I am having one doubt.Why is sizeof operator not in java ?Can anybody please help ?Thanks and RegardsRohit.
[164 byte] By [Rohit_India] at [2007-9-30 21:18:06]
# 1
How would you use it if it were present?
jverd at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...
# 2
> How would you use it if it were present?I'd use it for benmark testing, and to determine the applications general memory requirements.Here's an article: http://www.javaworld.com/javaworld/javatips/jw-javatip130.html
rkippen at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...
# 3

Use -verbosegc

Run the application

Try different memory sizes to see how this effects the rate of GCs.

This is the best way to determine the aplications overall memory requirements.

You can use a profiling tool such as JProfiler to deterrmine how the memory is used.

Note: these kind of tools have free trial periods.

Peter-Lawrey at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...
# 4
As I recall, the physical memory size of an object could differ from JVM to JVM; therefore, if someone were to use the results of a sizeof operator in there program for anything other than debugging, profiling, etc. then they could get unexpected results on another JVM.
jbish at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...
# 5

An object often refers to other objects. These object may or may not have multiple references (so counting them more than once is not accurate) The actual amount of memory used is often greater than you might expect if you are used to C/C++. The system also uses memory in sometime unpredicable ways. Many methods create transient objects adding to your memory requirement. Shared libraries, the stack, the JVM itself do not appear in the heap size but use memory. Files accessed by the application can be significantly effect the desirable file cache size.

The only real way to determine your application's memory requirement is to actively test the application, anything else is just guess work.

Peter-Lawrey at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...
# 6
java.lang.instrument.Instrumentation.getObjectSize(Object objectToSize)Returns an implementation-specific approximation of the amount of storage consumed by the specified object.
IanSchneider at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...
# 7
A good new feature of 5.0 (not in 1.4.x)My point would be that if you start with the calculated size for the objects you see, this can come up 100s of MBs short of the optimal memory size.
Peter-Lawrey at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...
# 8
If you want a benchmark an application, you should look into the Java Profiler Interface. http://java.sun.com/j2se/1.4.2/docs/guide/jvmpi/index.htmlThere are lot of profiling application that can tell processing and memory bottlenecks. http://ejp.sourceforge.net/
javaartist at 2007-7-7 2:50:47 > top of Java-index,Java Essentials,Java Programming...