memory management - Is there a way to lower Java heap when not in use? -


i'm working on java application @ moment , working optimize memory usage. i'm following guidelines proper garbage collection far aware. however, seems heap seems sit @ maximum size, though not needed.

my program runs resource intensive task once hour, when computer not in use person. task uses decent chunk of memory, frees after task completes. netbeans profiler reveals memory usage looks this:

java program memory usage

i'd give of heap space os when not in use. there no reason me hog while program won't doing @ least hour.

is possible? thanks.

you perhaps play around -xx:maxheapfreeratio - maximum percentage (default 70) of heap free before gc shrinks it. perhaps setting bit lower (40 or 50?) , using system.gc() might go lengths desired behaviour?

there's no way force happen however, can try , encourage jvm can't yank memory away , when want to. , while above may shrink heap, memory won't handed straight os (though in recent implementations of jvm does.)


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -