memory - How to shrink java heap space? -


this question has answer here:

i have java console app that's processing big xml files using dom. creates xml files data takes db. now, guess it's using large amount of memory but, surprise, it's not related bad code "java heap space not shrinking". tried running app eclipse using these jvm params:

-xmx700m -xx:minheapfreeratio=10 -xx:maxheapfreeratio=20 

i added the

-xx:-useserialgc 

as found out parallel gc ignores "minheap" , "maxheap" options. options graph of app's memory use looks this: java app graph

as can see, @ 1 point app takes ~400 mb of heap space, heap grows ~650 mb, few seconds later (when xml generation done) app goes down 12mb of used heap, "heap size" remains @ ~650 mb. takes 650 mb of ram! it's bizzare, don't think?

**is there way force jvs shrink availabe heap size to, 150% of current used heap?**like, if app needs 15 mb of ram, heap size ~20mb, when app asks 400 mb of ram, heap grows ~600 mb , drops ~20 mb app finish heavy-lifting operation?

you should use parallel collection , use -xx:-useadaptivesizepolicy. docs java 1.5 can't find more recent.

the implementation of -xx:+useadaptivesizepolicy used default -xx:+useparallelgc garbage collector has changed consider 3 goals:

  • a desired maximum gc pause goal
  • a desired application throughput goal
  • minimum footprint

the implementation checks (in order):

  1. if gc pause time greater pause time goal reduce generations sizes better attain goal.
  2. if pause time goal being met consider application's throughput goal. if application's throughput goal not being met, increase sizes of generations better attain goal.
  3. if both pause time goal , throughput goal being met, size of generations decreased reduce footprint.

edit

added "-" per op's suggestion.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -