How to find the number of bytes that Garbage Collector has freed up till now?

Viewed 32

Can anyone tell me How to find out the amount of memory that GC has freed up in an application until now?

1 Answers

The GarbageCollectorMXBean exposes garbage collector information, but only the number of collection runs and total time, and no information of the number of objects collected or memory freed.

So from the standard API, there's no way to get this information.

I assume that this would actually be quite an overhead for any garbage collector implementation to compute the actually freed size, so I doubt that this information can be obtained even from the actual GC implementations.

Related