Memory allocation : How much space does a reference occupy in Java?

java

Solution

That's not specified by the Java standard and thus you should not worry about it.

Technically, references are usually as big as the machine's word size, i.e. 32 bit on a 32 bit machine and 64 bit on a 64 bit machine, though some 64 bit JVMs use special magic to allow 32 bit references.

Problem

In Java we have written a code: ``` A a1; a1 = new A(); ``` How many bytes of memory is reserved when compiler compiles the code: ``` A a1; ```

Original source

Related problems