The code is very ugly/messy. Do you have a base class? What kind of object is your data?
What kind of data structure or abstract data type is this? There's a function/method called MakeWeak, so there's some kind of strength value involved? You have a leak? The problem might be bigger than that. Simplify. Make your code clearer to understand. On 13 April 2012 16:57, Gerhans <[email protected]> wrote: > 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 -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
