2

Suppose on my machine [x64, linux, 8g Ram], I set heap at JAVA_OPTS=-Xmx2048m and for tomcat as CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m".

Now at any moment, the memory requirement of application in tomcat goes beyond heap size specified at CATALINA_OPTS.

Will it give Out of Memory error? OR it will work without an issue as there is plenty of memory given to JVM(by JAVA_OPTS)?

1 Answer 1

2

When you are running your app in tomcat, then it will use the heap memory specified in the CATALINA_OPTS for the tomcat.

You can have multiple JVM running on the same machine and in this case, there is separate JVM for the tomcat and it's a different Java process.

Also, to check the memory usage of your application you can use the any profiler tool comes with the JDK. one such tool is visualvm.

Edit :- As OP asked what happen if the memory allocated to app is exhausted, then in that case outofmemory error comes.

And using above mentioned profiler tool, you can debug what causes this error and where most of the memory is consumed in your app.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks @Amit Khandelwal but my question is what will happen if memory required by app in tomcat will cross limit given to tomcat? in a situation where there is plenty of memory with JMV heap.
@d.Mon , then you will get out of memory error docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.