posted 18 years ago
Hi,
Welcome to JavaRanch!
Memory allocation happens when a program is running; the compiler doesn't allocate memory for anything. You may have read in a book that when you write
new Foo()
the compiler generates the instructions to allocate memory for a Foo object, and then to call its constructor; that is correct. But all the compiler does is put these instructions into the class files; it isn't until the program is executed that these instructions are carried out. Thus the compiler decides when to allocate memory, but it's up to the JVM to actually do it.