memorySegment.asByteBuffer().duplicate() causes multi-MB allocations

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Oct 26 12:17:23 UTC 2022


On 26/10/2022 11:37, Sebastian Stenzel wrote:
> There is is an expected amount of allocations all the time, both 
> "before" and "after", due to persistent invocations of the benchmarked 
> method. However due to different scaling of the "before" chart it 
> _appears_ like nothing after the first spike. When you zoom in on the 
> time axis, so that the spike is out of view, you'll see similar 
> patterns "before" and "after".

Yes, but it's the numbers that don't add up. In some instances there's 
only one call to `duplicate`, which seems to allocate ~350Kb. In another 
instance there's _two_ calls to `duplicate`, which, cumulatively, take 
less than 100Kb.

This doesn't make any sense, not only because it's not consistent, but 
also because 100Kb for a _single instance_ (which is just a wrapper 
around existing field) is huge! I'd expect a plain direct buffer view to 
take a couple of dozen of _bytes_ - not hundreds of kilos. So, even if 
there might well a real problem underneath, I'm not sure how much we can 
trust these numbers.

Maurizio



More information about the panama-dev mailing list