Skip to content

Tag: garbage-collection

Getting ‘allocation stall’ when enabling ZGC

I am testing the new zgc garbage collector that was included in java 11 since it promises really low latency. Our application is a real-time service that creates and destroys many objects per second and it does it in a multi-threaded environment using akka. When enabling zgc by passing the options -XX:+Unlock…

Why is SerialGC chosen over G1GC?

I am running Java on very similar VMs and I can’t find the explanation why the SerialGC is chosen over G1GC in one case. It’s the same Java version, same OS, same VM instance type on AWS, and I suspect the only difference is container settings but I do not know how to pinpoint what changes. Is the…

Minor GC pause times are too higfh. possible reasons?

I Am experiencing a regular high minor GC pause times(~ 9seconds). The application is a server written in Java, executing 3 transactions/seconds. Eventhough there’s no I/O excessive activity Heap parameters are: What are the possible reasons for such minor gc pause times values? Answer As the other answ…

Are lambdas garbage collected?

If I’m not mistaken, under certain situations a lambda in Java is generated as an anonymous class instance. For example, in this code the lambda needs to capture a variable from the outside: Does it means that the garbage collector will claim the lambda as an object? Answer No it won’t; this is no…

Measuring time spent on GC

Suppose I am testing a Java server application. I know how much time it takes to finish the test. Now I’d like to know how much was spent on GC during that test. How can I do it? Answer The simplest way is to use the -Xloggc and -XX:-PrintGCTimeStamps options when starting up your JVM. I think it prints…