How do you find the root of the problem?
I just made a simple Spring Boot app to test an API, it began at 200mb, slowly but surely increasing, after 8 hours is nearly at 300mb
I haven't even touched it, it's just idle in the background
How do you find the root of the problem?
I just made a simple Spring Boot app to test an API, it began at 200mb, slowly but surely increasing, after 8 hours is nearly at 300mb
I haven't even touched it, it's just idle in the background
For further actions, you may consider blocking this person and/or reporting abuse
Olga Lugacheva -
Pete -
gameon gameover -
Emanoel Carvalho -
Top comments (12)
You can use a profiler to inspect the JVM at run time.
jmap is a free basic CLI tool you can use to inspect a JVM. You can dump the heap, monitor live heap memory and get a simple histogram of objects using this tool.
jconsole is an upgrade to jmap with a GUI and more options.
VisualVM is a great free tool with way more options.
All the above tools are shipped free with a JDK distribution. You can find all of them in <JDK>/bin directory.
You can use all these tools to connect to a running JVM and inspect the internals.
I'm checking out those as we speak, thank you very much!
Are you running it with any memory args like
-Xmx
?No I actually didn't, would that be the problem?
I removed them because I wanted to see if the little app was stable, then I came across said memory leak
I would try setting a max heap and see how that affects it. I can’t remember exactly what the calculation is but the JVM sets its default memory settings based on the overall system memory. If it’s assuming that it has a lot of memory available to it, it may allow the heap to grow without garbage collecting it. So, could be if you constrain the heap some more, the JVM will perform more garbage collection and keep the overall usage lower.
But, like other people are saying, your best window into what’s going on memory-wise is to take heap dumps and analyze them with a memory analyzer (MAT is a good free one that does leak suspect reports).
I think this would be your best option. Restrict max heap size an check if your app runs into an OutOfMemoryError. If that happens, use one of the mentioned tools to analyse your heap (take snapshots of your heap at different points in time, see what objects might accumulate).
But first, I'd also recommend to verify there's a memory issue
I did it yesterday, and ran into a memory error (not sure which), logs said the JVM killed the child or something... I should've saved that log I'm sorry
But I do am working on it, already taking a course on JVM memory :)
You'll want to use a tool like JavaMelody or JProfiler to be able to work out what's going on inside the JVM. You may want to look at taking a Heap Dump and analysing it; JProfiler has a pretty good Heap Walker which will allow you to sort objects by size or the number of instances, and most likely your top object here is the leak.
thank you very much :D
Share your code repo.
I forgot to give an update!
I wasn't able to edit it because most of the code was from work, so I made a quick project from scratch with nothing but the API and that one was working fine, therefore I had nothing to show you :(
But I'm already working out the problem based on the suggestions given
Will do tomorrow, I need to remove a couple things from work, I will reply to you again tomorrow