Arena/Segment allocator and zero initialized
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Jun 5 17:57:11 UTC 2024
On 05/06/2024 18:40, Jonathan Rosenne wrote:
> Hi,
>
> SegmentAllocator is an interface. So is Arena. It should be quite possible to have an derived implementation that call Arena.allocate and zeroizes the memory if this is desired.
Yes, this is possible but I believe Remi wants to avoid "double
zeroing", see other thread.
> In general it is counter-productive if the segment is used for output as zeroizing is CPU intensive..
Now that you say that, looking back ar Remi's example (which is
collections backed by memory segment) I'm no longer sure as to why we
need zeroing.
Sure, say, a List is created with an initial slab of 1024 bytes, and if
these bytes are not zeroed we might read "wrong values". But...
The List interface has a "size". The size starts off at zero. So you
can't read elements that haven't been inserted yet.
If that's the case, isn't it true that nobody can read a value _before_
it has been explicitly set by the user? And, if so, why is zeroing a must?
(of course I'm not saying that, in general, one should not be able to
enforce zeroing where that's required, but in this specific case, do we
need that?)
Maurizio
More information about the panama-dev
mailing list