Hi - I'm having some trouble preventing a leak of the data parameter
passed to ObjectTemplate::SetAccessor(). I'm attempting to use a
Persistent handle to an externally new'd pointer as the 'data'
parameter, but the dataDeleterFn I pass to MakeWeak() never seems to
fire. More specifically, I'm attempting to replace the Accessor on the
fly, which of course is the only reason I would expect the data to be
cleaned up. I've tried to force this by calling my setAccessor()
function repeatedly (100,000+ times) and am successfully forcing V8 to
garbage collect overall, but watching my app in Instruments it's clear
that it's leaking memory. Does anyone have any insight into this?
void setAccessor( const std::string &propName, void *data )
{
v8::HandleScope handleScope;
v8::Local<External> dataExternal = v8::External::New( data );
v8::Persistent<External> dataPersistent =
Persistent<External>::New( dataExternal );
dataPersistent.MakeWeak( accessor, dataDeleterFn ); // <--- never
fires
mInstanceTemplate->SetAccessor( v8::String::New( propName.c_str() ),
getterFn, setterFn, dataPersistent );
}
Thanks in advance...
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users