> On Sep 29, 2015, at 8:40 PM, Yadong Liu <yad...@fingerprintplay.com> wrote:
> 
> So my question is: what I need to do to make sure the my Objective-C object's 
> dealloc() is called immediately as soon as my JavaScript code removes all 
> references to the object?

JavaScriptCore manages storage with garbage collection. With garbage 
collection, there is no guarantee that an object will be deallocated as soon as 
code removes all references to an object; that won’t happen until garbage 
collection later determines it can deallocate the object. The object will be 
deallocated some time later, but not promptly.

If you need to promptly deallocate a particular Objective-C object at a well 
defined time, then you will need to change your design so that the deallocation 
of the object in question is driven by an explicit function call, not by the 
timing of garbage collection. Typically that means that work that was done in 
the “dealloc” method is instead done in some other method, one called 
explicitly from JavaScript. The object you pass to -[JSValue 
valueWithObject:inContext:] should typically be a small wrapper object, not a 
large object that would drive a need to deallocate it promptly.

There may be some other JavaScriptCore experts on the list that can elaborate 
further.

By the way, this mailing list is normally for the development *of* WebKit, not 
for tips on how to use it properly. There are some other lists for that, such 
as http://lists.webkit.org/mailman/listinfo/webkit-help 
<http://lists.webkit.org/mailman/listinfo/webkit-help> and 
http://www.lists.apple.com/mailman/listinfo/webkitsdk-dev 
<http://www.lists.apple.com/mailman/listinfo/webkitsdk-dev> — I decided to 
answer your question here even though it’s off topic. Please see 
http://www.webkit.org/contact.html <http://www.webkit.org/contact.html> for 
details.

— Darin
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to