In my tests, it works, with the MakeWeak-callback. The callback ist
called the first time, when there are about 400 unused Persistent
Objects allocated
i use following js code to test, where the fuction myobj returns a
Persistent Object
for (var c=0;c<200000;c++) {
var x=myobj()
}
unfortuanatly, when i have allocated and deallocated about 160000
objects, my program crashes. it looks like the GarbageCollector isn't
freeing the Persistent Object after calling theMakeWeak-callback.
in my callback i only delete my c++ object, do i have to do something
with the Persistent<Object> ?
markus
On 26 Sep., 22:55, Garry <[EMAIL PROTECTED]> wrote:
> Hey - did you solve this problem? I'm facing the same thing right
> now..
>
> I want to make an object that I push into Javascript, then when JS
> garbage collects it I get a callback so I can delete the c++ side
> pointer. Is this the wrong approach?
>
> garry
>
> On Sep 22, 9:57 am, [EMAIL PROTECTED] wrote:
>
>
>
> > Thank you for the example.
> > I also use:
> > ........
> > Persistent<Object> self = Persistent<Object>::New(args.Holder());
> > self.MakeWeak(0, Point_Destroy);
>
> > self->SetInternalField(0, External::New(p));
> > return self;}
>
> > void Point_Destroy(Persistent<Object> self, void* parameter)
> > {
> > Local<External> external =
> > Local<External>::Cast(self->GetInternalField(0));
>
> > deletestatic_cast<Point*>(external->Value());
>
> > }
>
> > but the "Point_Destroy" Function is never called. So when should it be
> > called in your example?
>
> > Thanks
> > bg- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---