System.gc() causes for jcl (BufferPoolMXBean)

Bernd Eckenfels ecki at
Fri Jun 19 19:42:48 UTC 2015

Hello Alan,

Am Fri, 19 Jun 2015 09:10:44 +0100
schrieb Alan Bateman <Alan.Bateman at>:

> On 19/06/2015 07:00, Bernd Eckenfels wrote:
> >> - why is BufferPoolMXBean not tracking allocation failures,
> >> allocation count, alignment flag and maximum size (maybe even
> >> modifyable). Would it be worth to contribute something in this
> >> area or is that supposed to be covered by some events (and if yes,
> >> when will they be exposed to JMX).
> >
> When we created BufferPoolMXBean (in JSR-203) then the goal was to
> make it easy to monitor current usage. It wouldn't be hard to track
> peak usage if that is important.

From my point of view tracking native allocations in "internal" pool
(via Unsafe.allocate) is hard. (see my other discussion on
instrumenting Unsafe). Making some of the users (especially
DirectByteBuffers) more transparent would be a good thing.

This includes peak usage but also allocation rate and especially the
backoff/system-gc case. So from my side, I think it is a good thing to
add some metrics here and I am willing to work on a patch.

> Direct buffers have not been page
> aligned for some time so that is probably not worth trying to expose.

I just saw it in the code and the fact that there is still capacity vs.
size, and even some mentions of page alignment in 8:

But in my proposed patch I did not expose the alignment and agree its
not needed.

> The nio-dev and serviceability-dev would be the right place to being 
> proposals in this area.

Very well, I will subscribe nio-dev and include it in the discussion.

Before I do so, I have one question which is serviceability related: My
patch proposes a (partial) solution which is based on the
existing MBeans. I do however wonder if this is also interesting for
perfcounters and/or JFR. Is there a alternative API which would be able
to distribute those statistics into all/other subsystems. Especially
the "out of direct memory need to wait x millis" would be a very
interesting FR event to capture. Any recommendation what I should look
at to understand them?


More information about the serviceability-dev mailing list