Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM and GC tuning - theory for no Full GC

I have large scale application with two type of objects: long living (cache) and short living (request-process-response). Theoretically, with this type of application, I think it is possible to configure Young vs Old spaces, so Old space consumption is constant, resulting in no Full GC.

I've changed newSize-maxNewSize params, but, Old heap continues to rise until Full GC. After each Full GC, consumption is down to 20% (cache takes 20%). For some reason, my objects gets into Old space. I have two suspects why are moved to Old space:

  • Per this article: http://chaoticjava.com/posts/gc-tips-and-memory-leaks/ it's told if you have big objects allocated, those go directly to Old space. Is this true, and if it is, is there JVM Option param that can set object size threshold for Young space?

  • If I understood the process correctly, objects are switched between To-From survival sections before are moved to Old section. Is there param that can set how many switches between To and From is to be done before moving to Old space?

Any other tips?

Thanks, Amar

like image 211
Amar Avatar asked Jun 03 '11 10:06

Amar


1 Answers

It does sound like your survivor spaces are not big enough. You need to make them large enough that no objects need to be collected. An object is only switched into and out of survivor space once.

If you are allocating large objects, can you use an Object pool for them avoiding the need to GC them. Have you considered using an object pool for your request/process/response data as well? e.g. a simple one is to use a ThreadLocal.

Have you tried the G1 collector which is designed to progressively collect all your memory and reduce the big hit of a full GC.

like image 92
Peter Lawrey Avatar answered Sep 20 '22 17:09

Peter Lawrey