I want to know when a program written by Java is running,its classes will be all loaded on the main memory?

eclipse, java

Solution

No it's fine, because of virtual address space and virtual memory. Read these:

http://en.wikipedia.org/wiki/Virtual_memory

http://en.wikipedia.org/wiki/Virtual_address_space

Virtual memory means that you can load a large amount into memory and the unused sections are saved to disc and are moved out of physical RAM.

Virtual address space means that each process (one example of a process is your Java program) has its own address space, so it does not 'steal' addresses from other processes.

Problem

When a program written in Java is running, will all of its classes be all loaded into the main memory? If so, isn't it a waste of RAM?

Original source