Link to home
Get AccessLog in
Avatar of JeffBeall
JeffBeallFlag for United States of America

asked on

java jar file memory alocation

I have a jar file on a ubuntu server, and the recommended settings is

java -Xms512M -Xmx1G -jar /path/to/jarfile

I have tried this, and assigning more memory

java -Xms2048M -Xmx4096M /path/to/jarfile

but it seems to work best to just run the jar with no parameters

java -jar /path/to/jarfile

I'm trying to figure out how this could be? does java just use what it needs, so if i set a 4gb limit for instance, and it would be better to have more that is why it's better not to have parameters? If I don't have any parameters, does java just take what it needs?
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
Avatar of JeffBeall

ASKER

so, it sounds to me like there isn't a reason to allocate a memory size. it seems that java will decide, and i would assume, do a better job of deciding than i would.
thanks for the help
so, it sounds to me like there isn't a reason to allocate a memory size. it seems that java will decide, and i would assume, do a better job of deciding than i would.

I'd say there isn't yet. But if you get any out of memory errors it would be a good idea to increase the JVM size.

As an advice always use the recommended settings. In your example if they recommend you start your application with half of GB and maximum of 1GB then start it like that, the application probably consumes that much memory.