简体   繁体   中英

Large collection of long lived objects vs garbage collection

In my application I have a large collection of long lived objects. I am using relatively large heap-size of 100gb (xmx and xms) and once my application hits about 30gb of used heap the garbage collector starts a really long stop-the-world pause that can take up to 15 minutes. After a while the application terminates with the gc overhead limit exceeded exception.

I want to keep all of the objects for whole application's lifetime, so freeing any memory is not an option.

I know that one of the solutions would be to use off-heap storage, but I'd like to avoid that at the moment.

The other would be to tune garbage collector's parameters. I tried with different algorithms and young generation sizes, but it didn't help and I don't know where to go from there.

My problem lied in wrong order of jvm parameters. I wasn't aware you have to specify all of them before -jar switch.

I ended up setting the bigger heap size correctly and using G1GC with relatively small young generation (ratio 20). Now the GC pauses are much more manageable.

Performance-wise rewriting the code for off-heap storage would probably be preferable in this use case though.

I deleted my comments to avoid potential confusion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM