Java memory usage graphics
andreigaevsky
HOBBYOP

7 months ago

I run my java app with the command
|
java -Xms256m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heapdump.hprof -verbose:gc -XX:+PrintGC -XX:+PrintGCDetails -jar target/myapp.jar

From logs I see GC frees a lot of memory
GC(12) Pause Young (Normal) (G1 Evacuation Pause) 176M->35M(256M) 7.501ms

But in Metrics I see usage about 1GB constantly.

So my question is what is using so much memory?

$10 Bounty

5 Replies

Railway
BOT

7 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


turborx
FREE

7 months ago

hi, the memory graph shows cumulative usage over time, not current usage, so it keeps rising even if your java app uses only ~250mb. also, the jvm reserves heap by default unless you limit it. to control this, set flags like -Xms128m -Xmx256m to cap memory use and reduce noise in the graph. it's normal jvm behavior.


turborx

hi, the memory graph shows cumulative usage over time, not current usage, so it keeps rising even if your java app uses only ~250mb. also, the jvm reserves heap by default unless you limit it. to control this, set flags like -Xms128m -Xmx256m to cap memory use and reduce noise in the graph. it's normal jvm behavior.

andreigaevsky
HOBBYOP

7 months ago

Hi! Thanks for your answer!
So the graph shows cumulative usage since last reload/restart? But why?

I mean I set "Max amount of Memory to allocate" to 1GB in the app settings and the graph does not exceed this value. But once it does I'm getting "ran out of memory".
Does it mean that the setting "Max amount of Memory to allocate" means max allocated memory since app started? And not max RAM available?


aleks
HOBBY

7 months ago

The Railway setting of "Max amount of memory to allocate" is different from the JVM's cap - I'd recommend moving the cap farther up on Railway's side and capping it with JVM flags instead as @turborx described.

Also, no, the graph should show current memory usage, not cumulative.


aleks

The Railway setting of "Max amount of memory to allocate" is different from the JVM's cap - I'd recommend moving the cap farther up on Railway's side and capping it with JVM flags instead as @turborx described.Also, no, the graph should show current memory usage, not cumulative.

andreigaevsky
HOBBYOP

7 months ago

Hi, thanks!

I set less memory with JVM's cap and increased on Railway's side. Very slowly, but the graphic's line is growing.
If it should show current usage why it's not reacting to the garbage collector? Maybe it shows allocated memory which is constant - this can explain it.
But why it's constantly growing?


Loading...