How to analyse memory leaks in Java Play Application?

My application runs into OutOfMemoryError: Java Heap Space. So I installed Eclipse Mat. It needs a heap dump. How to create Heap Dump for Java Play application? Can I see live memory analysis?. Some analysers needs Heap Dump but how Do I get it for play framework?.
According to play docs, we can use YourKit Analyser (Its paid).Actually, I want to understand any tool for play in deepth its configuration in sbt/any other property file, working, how it shows exactly shows memory leaks in particular java classes?
Thnaks.

1 Like

Trying adding these parameters to the run command:

-J-XX:+HeapDumpOnOutOfMemoryError -J-XX:HeapDumpPath="<DIRECTORY_LOCATION>"

If the OOM occurs, these parameters should cause an *.hprof file to be created in that location. Eclipse MAT can read those files and you can then look at what your application looked like in the moment that it had the OOM.

As for

Actually, I want to understand any tool for play in deepth its configuration in sbt/any other property file

I don’t think that exists, that’s just a case of understanding your own code.

2 Likes

Thank You. I was able to add jvm parameters while running application locally. My Application is hosted on Server, so how to add these parameters(in application.conf/build.sbt where to add) for app on server?

Hi @chaitanya.anpat,

Nothing special, just add these parameters to the JVM command used to start the application.

I recommend that you read more details at the pages listed here: https://www.playframework.com/documentation/2.6.x/Production

Best.

thank you. I have added the jvm parameters.