diff --git a/src/smalloc.cc b/src/smalloc.cc index a48fd7c88a1..35220ac09b5 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -206,7 +206,7 @@ void AllocDispose(Handle obj) { HandleScope scope(node_isolate); if (using_alloc_cb && obj->Has(smalloc_sym)) { - Local ext = obj->Get(smalloc_sym).As(); + Local ext = obj->GetHiddenValue(smalloc_sym).As(); CallbackInfo* cb_info = static_cast(ext->Value()); Local obj = PersistentToLocal(cb_info->p_obj); TargetFreeCallback(node_isolate, obj, cb_info); @@ -252,6 +252,7 @@ void Alloc(Handle obj, cb_info->cb = fn; cb_info->hint = hint; cb_info->p_obj.Reset(node_isolate, obj); + obj->SetHiddenValue(smalloc_sym, External::New(cb_info)); node_isolate->AdjustAmountOfExternalAllocatedMemory(length + sizeof(*cb_info));