Allocation of memory

Hi All,

I'm really sorry i'm askin a naive question. when we create a new string object or for that matter any object by writing

String str =new String("Hi!");

who allocates memory for the object; the JVM or the underlying operating system. Also i would like to have some references for the JVM.

[382 byte] By [Cipher1024a] at [2007-10-2 21:46:45]
# 1

When the JVM starts up it reserves (but doesn't commit) a range of addresses to use as the Java Object heap. When you write new String("Hi!")

part of that reserved space is committed to represent the char[] for the "Hi!", and another part is committed for the String instance that holds a reference to the char[]. When there are no more references to the String, the JVM recovers the space for use as other instances.

There's a whitepaper on memory management in the HotSpot virtual machine at http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf

Peter.Kessler@Sun.COMa at 2007-7-14 1:02:22 > top of Java-index,Desktop,Runtime Environment...