R
Railway•10mo ago
Lelebees

Java app using abnormal amount of ram

Attached you see the RAM usage graph of my project. I am running a discord bot with a Java Spring Boot application, and on my local device, the app eventually uses <200 mb of RAM, but on railway, the ram usage continues to increase. I found a StackOverflow post that tackles a similar issue, but updating my Dockerfile with the runtime flags did not deliver noticeable changes (see the last deployed commit, compared to the rest). Ideally, I don't have to manually call the GC, although it is an option available to me. Does anyone have any recommendations for getting my Java app to release unused RAM memory?
Stack Overflow
Java 17 app shows very high RAM usage in docker
I have a application that during idle times usually only needs 1GB of RAM however when I launch it inside in docker, then it shows much higher RAM usage (5GB) from the outside. The JVM metric show ...
No description
Solution:
It looks like shenandoahGC has given my app a healthier ram graph. Thank you all for your help!
Jump to solution
17 Replies
Percy
Percy•10mo ago
Project ID: 1a73e8f4-a61d-4a67-9bd7-3539b677698b
Lelebees
Lelebees•10mo ago
1a73e8f4-a61d-4a67-9bd7-3539b677698b
Brody
Brody•10mo ago
that's more so looking like a memory leak to me
Lelebees
Lelebees•10mo ago
If it was, then i'd be able to reproduce that locally, no?
Brody
Brody•10mo ago
do you build from the dockerfile file and run the resulting image ?
Lelebees
Lelebees•10mo ago
Yes
Brody
Brody•10mo ago
well it's not like railway is making up metrics
Lelebees
Lelebees•10mo ago
According to stack it's because java isnt by default configured for containers, which is why i asked here if people had knowhow of how i should configure the dockerfile My apologies if I gave you the wrong answer to this question. I mean that Railway is running from the Dockerfile, and my local machine is the bare Java app. Local machine has less ram usage then the deployment on railway. The attached stackoverflow post claims that java won't unclaim heap space the same way if it's running in a container. There were runtime flags i could add to the dockerfile that'd supposedly fix this, but this did not have the desired effect
Brody
Brody•10mo ago
what effect did it have, if any
Lelebees
Lelebees•10mo ago
Practically none if it didnt make it worse
Dayblox
Dayblox•10mo ago
Are you sure the flags were taken into account when deploying?
Lelebees
Lelebees•10mo ago
How can I verify that?
Dayblox
Dayblox•10mo ago
Logs
Lelebees
Lelebees•10mo ago
A quick search doesn't give me any hits for the flags, so i guess they're not being considered I'll play with those when i get back home and see if i can get it working. Probably misusing them I am the most smoothbrained ape on this planet Flags go before the -jar flag 🤦
Dayblox
Dayblox•10mo ago
Did it help your heap usage?
Lelebees
Lelebees•10mo ago
Going to redeploy now and see if it helps I've had her run for a bit and it definitely looks like it helped. RAM usage continues to grow but does so much slower I'm trying if ShenandoahGC helps more. It looks promising so far
Solution
Lelebees
Lelebees•10mo ago
It looks like shenandoahGC has given my app a healthier ram graph. Thank you all for your help!