I have been testing some code, and I want the WeakReference objects to
be deleted at will ... this would be especially useful in applications
that need a little more control over when weak ref objects are
collected ... and ensuring that they are collected when the
application is closed.
Suppose you clear the current context you are working on like so:
context.Dispose();
context.Clear();
You wont know when the GC will kick in and do its thing ... however,
after reading some code, i believe there to be an extremely simple
solution.
Add this function to api.cc:
bool v8::V8::RunGC()
{
if(!i::Isolate::Current()->IsInitialized())
{
return false;
}else{
i::Heap *heap = i::Isolate::Current()->heap();
heap->CollectAllAvailableGarbage();
return true;
}
}
And then update include\v8.h and src\v8.h to include this definition
in the public member area:
class V8EXPORT V8 {
public:
// Run Garbage Collection
static bool RunGC();
.....
}
After testing this with the point example and the weak ref example
from http://create.tpsitulsa.com/wiki/V8/Persistent_Handles I am now
reliably(I hope) able to invoke the objects destructor. Is there any
reason that this method would be bad? If anybody would like to see the
code I am working with I can post it.
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users