[webkit-help] how to free a function callback

scostas scostas at det.uvigo.es
Mon Apr 5 12:56:38 PDT 2010


I've created a new method which receives a function as a parameter, and 
stores it in a pointer in C using JSValueToObject(). Then, in my C code, 
when I want to inform JavaScript about an event, I call that function 
using JSObjectCallAsFunction().

My question is: do I have to do something to ensure that the object 
never becames invalid because the garbage collector frees it? Let's say 
that, instead of a function, it's an object's method, instead. In a 
system with reference counters I just should increment it, but with a 
garbage collector I have to add a "pointer" inside JavaScript VM, if it 
has not been done already...

The other question is: what do I have to do, when a page is reloaded, to 
safely dispose this object and ensure that the JavaScript VM frees it? 
Again, with reference counters, I just should decrement it, but with the 
garbage collector I'm not sure how to ensure that any possible reference 
has been erased.


More information about the webkit-help mailing list