On May 15, 2014 3:34 AM, "Dmitry Lomov" <[email protected]> wrote: > > Hi Trevor, > > Since V8 does not know how the memory backing an ArrayBuffer has been allocated in this case, there is now good way for V8 to free it.
Since the user has to define the ArrayBufferAllocator, V8 isn't in control of how memory is allocated regardless. Technically using preallocated memory could be hacked in by having the user defined allocator use the user allocated memory instead. Meaning, it's possible but an inappropriate hack of the API. So I'm missing why entrusting the user to only pass in data that's been allocated properly is an issue. > Just like previously with "external indexed data", the way to do it is to use a weak persistent handle for the ArrayBuffer to get a notification when ArrayBuffer becomes unreachable and then deal with your memory block accordingly. This removes the performance benefit of using ArrayBuffers. I noticed how much work went in to making ArrayBuffers faster, and I would like to take advantage of this as much as possible. One additional issue. Say ArrayBuffer is left to allocate the memory correctly. Why is it I can't simply get a pointer back out for a simple operation like memcpy() without needing to go through all this? As it stands, the API requires that I either for loop through and copy in values or use a weak persistent handle. Neither of those are particularly appealing. Can we work out a way to allow the user to get a pointer back from the ArrayBuffer, also have an API sanctioned way of using preallocated memory, without needing to use a weak persistent handle? -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" 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.
