Avatar of JeffBeall
JeffBeall
Flag 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?
JavaJSPJava App Servers

Avatar of undefined
Last Comment
girionis

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
girionis

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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.
JeffBeall

ASKER
thanks for the help
girionis

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes