On 2015/07/02 at 17:09:11, binji wrote:
On 2015/07/02 at 11:04:41, jarin wrote:
> On 2015/07/01 18:52:54, binji wrote:
>
> Hmm, now I am a bit confused about lifetime management of the shared
array
buffer contents. Why does the worker have to do explicit management of the
array
buffer contents? I thought there would be some reference counting on buffers
that would magically take care of this. Or is this taking care of the
buffers
that were not collected by the GC?
>
> Adding Jochen who might be less confused than me.
The ArrayBuffer (all of this applies to SharedArrayBuffers too) object is
always owned by the isolate that created it. And the memory is always
allocated
using the ArrayBuffer::Allocator. But whether the memory is free'd when the
object is garbage collected depends on whether the ArrayBuffer is
externalized.
AIUI, most ArrayBuffers start out as non-externalized. When they're
transferred
to another isolate, they're externalized which basically means that the
isolate
that owns the object shouldn't clean up the memory too. At this point, some
higher-level system has to manage cleaning up the memory that is shared
between
isolates. In Blink this is a ref-counted structure, that is attached to the
DOM
wrapper objects. In d8, it seemed simpler to manage that memory directly in
the
Shell class or the Worker.
Ah, but it looks like the ArrayBuffer::New static constructor can specify
that
the array buffer should be created non-externalized. I'll give that a shot,
because it means that the worker won't have to manage the memory.
SharedArrayBuffer will still have to be managed by the Shell, however.
the non-externalized ctor can't be used with shared array buffers, as that
would
result in double-frees
https://codereview.chromium.org/1215233004/
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.