Skip to content
This repository
Browse code

Don't use v8::AdjustAmountOfExternalAllocatedMemory

cSys::alloc and cSys::free are used by the machinery that manages the
mappings between v8 objects, o3-xml objects and libxml nodes. When
alloc/free are called its data structures may not be in a consistent
state.

AdjustAmountOfExternalAllocatedMemory can trigger a v8 garbage
collection, which in turn causes o3-xml to update some reference counters.
Sometimes this makes o3 release blocks of memory, which is risky
business when its internal data structures are inconsistent.

Not calling AdjustAmountOfExternalAllocatedMemory should not have a
meaningful impact here.
  • Loading branch information...
commit 0afc402abfcf01f99b326d72d23872dc9b225794 1 parent 8d49b92
Bert Belder piscisaureus authored

Showing 1 changed file with 0 additions and 2 deletions. Show diff stats Hide diff stats

  1. +0 2  include/cSys_posix.h
2  include/cSys_posix.h
@@ -620,7 +620,6 @@ struct cSys : cSysBase {
620 620 void *ptr = ::malloc(size);
621 621 *(size_t *) ptr = size;
622 622 m_overall+=size;
623   - v8::V8::AdjustAmountOfExternalAllocatedMemory(size);
624 623 return ((size_t *) ptr) + 1;
625 624 #else
626 625 return ::malloc(size);
@@ -631,7 +630,6 @@ struct cSys : cSysBase {
631 630 {
632 631 o3_trace_sys("free");
633 632 #ifdef O3_NODE
634   - v8::V8::AdjustAmountOfExternalAllocatedMemory(- * (((size_t *) ptr) - 1));
635 633 m_overall-= *(((size_t *) ptr)-1);
636 634 ptr = (void *) (((size_t *) ptr) - 1);
637 635 #endif

0 comments on commit 0afc402

Please sign in to comment.
Something went wrong with that request. Please try again.