This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I know we can set -Xmx256m kind stuff in the eclipse run configuration panel's arguments/ Question --
1. what's the default heap size for each application ?
2. when you set "-Xmx256m", does it mean you allocate that much memory for your application ? Then don't you need to consider what's the memory of your PC ? what if you set -Xmx1024m but you don't have 1024M memory ? Plus, even if you have 1024M memory, if you set -Xmx 512m, then does it mean other application can only share the remaining 512m ?
3. in a production env, if each application set -Xmx512m, then potentially each of them consumes so much memory, is that true ?
Fundamentally, I want to understand when you do "java myapp -Xmx512m", does it mean you allocate at most 512M to "myapp" only ?
It means that the Java heap can grow to that size, at maximum, for that application. It will generally start smaller, and will grow as needed up to that size, but no larger. The maximum amount used by your application will actually be larger, because the Java heap size doesn't count the space taken up by the VM implementation, etc.
In any case, do you understand the idea of "virtual memory"? All modern operating systems effectively use your disk space as extra RAM, so that the total amount of memory needed by all running programs can actually be larger than the amount of physical memory you have. How well the computer handles that situation depends on the OS and on the hardware, of course.