[v8-users] Freeing C++ object wrapped in V8 Handle

Tue, 24 Dec 2013 21:33:01 -0800

Hello!
For example, I have the *Handle<Object> testobj*, which contains some 
pretty huge C++ structure as an Internal field. So, when I *Close() *the 
current handle scope, this handle is deleted (unless I return it to the 
outer world). Garbage Collector frees the memory on the next run, it frees 
*testobj*, but does it really frees the memory, which was occupied by the 
C++ structure? Code sample:

Handle<Object> wrapMatrix(Matrix *matrixToWrap)
{
    HandleScope handle_scope;
    Handle<FunctionTemplate> matrix_template = FunctionTemplate::New();
    Handle<ObjectTemplate> matrix_instance_template = 
matrix_template->InstanceTemplate();
    matrix_instance_template->SetInternalFieldCount(1);

    Handle<Object> matrix_instance = 
matrix_instance_template->NewInstance();
    matrix_instance->SetInternalField(0, External::New(matrixToWrap)); 
(matrixToWrap takes ~500 MB in memory)
    ...
    handle_scope.Close(<SOME OTHER OBJECT>);
}

So, when *handle_scope.Close* is performed, is the memory of *matrix_instance 
*freed completely?

-- 
-- 
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/groups/opt_out.

Reply via email to