Hi v8-users,
We have an ArrayBufferAllocator implementation that counts how much memory has been allocated. It basically looks like this:
class AllocatorImpl final: public v8::ArrayBuffer::Allocator {
AllocatorImpl(): allocated(0) {}
inline size_t getMemoryUsage() const { return allocated; }
void* Allocate(size_t length) {
return calloc(length, 1);
void* AllocateUninitialized(size_t length) {
void Free(void* data, size_t length) {
We're observing something strange: Sometimes (very rarely!), the `allocated` value drops below zero and wraps around, apparently indicating that V8 has Free()'d more than it Allocate()ed. However, there don't seem to be any issues with double-frees or freeing an invalid pointer.
Any idea what could lead to this? Is it possible for V8 to pass a different `legth` value to Free() than it passed to Allocate()?
Unfortunately I have no idea how to reproduce this reliably. It only happens very occasionally in production. :/
-Kenton