Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

memory is allocated to the JVM to run the java application

Hi,

I was reading as

 'memory is allocated to the JVM to run the java application'


How and who allocate memory to JVM. I never remember allocating memory to JVM on my windows laptop. What is the maximum memory i can allocate to JVM.


I see my windowns 7, 64 bit laptop has installed memory(RAM) of 8 GB. How and where to assign memory to jvm. By default how much memory is allocated to JVM. Any links resources ideas highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of Ken Butters
Ken Butters
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

As in attachment do i need to set(like -Xms512m) for every java program i run.

What is the default value.

 java -Xms512m -Xmx512m


what is the difference between initial and maximum heap size. Can they be same?

Please advise
The default is defined in your eclipse.ini file.

For example... my eclipse is installed at :

C:\Program Files (x86)\eclipse

in that folder is eclipse.ini.

inside eclipse.ini is following:

-Xms40m
-Xmx512m

Initial and maximum heapsize can be the same.

The difference is initial Heap size is the size that will be allocated to heap when the JVM first starts.  

If more is needed then heap size will be increased up to maximum of whatever is defined for Maximum heap size.

If you set maximum size = initial heap size... then heap size cannot be increased if JVM runs out.

You only need to worry about it if your particular java application runs out of memory.

The default values in eclipse.ini file can be overridden for a specific java application by following instruction in my previous post ---> here : https://www.experts-exchange.com/questions/28362322/memory-is-allocated-to-the-JVM-to-run-the-java-application.html?anchorAnswerId=39851455#a39851455
Avatar of gudii9

ASKER

I checked eclipse.init file it shows me

-Xms40m
-Xmx512m

same as yours.

The difference is initial Heap size is the size that will be allocated to heap when the JVM first starts.


When the JVM starts ? is it at the start of the eclipse or is it start of the web or application server like tomcat/weblogic etc within the eclipse.
Is there is separate jvm for eclipse and web or application server?

please advise
This is getting off topic from your original question....
How and who allocate memory to JVM.

I'd really rather not chase down a bunch of new questions within this thread as that can go on forever.

That being said... eclipse is an IDE... a development environment.  it includes all sorts of tools to make development in Java easier.

For example ... when you use eclipse... and tell it to start your java application... it will issue the javac command to compile your changed source files.  You don't have to specifically type "javac"... but eclipse will do it for you when you build your project or when you start your application.

You could do the same thing at a DOS prompt... it's just more cumbersome.

Likewise... whenever you start a Java Application... regardless of whether it is in Eclipse, the DOS prompt, or on a web server... That invocation of the java application will require that a JVM be present to execute the bytecode.  

So yes... there is a separate instance of the JVM for a web server, than there is for the case where you are running it locally within eclipse.

Within eclipse you can also include and start up a webserver, like Apache Tomcat or whatever... but no matter how it is done.. in the end... there is a JVM that must be running to execute your code... and the memory allocated to that specific JVM may need to be adjusted for your specific situation.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial