<div dir="ltr"><div>Thanks for your quick response to my first post to the list and apologies for being off-topic. Your answers/suggestions make lot of sense to me. If any other JavaScriptCore experts want to weigh in with their recommendations, it would certainly be much appreciated as well. <br><br></div>- Yadong<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 29, 2015 at 10:04 PM, Darin Adler <span dir="ltr">&lt;<a href="mailto:darin@apple.com" target="_blank">darin@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><div><blockquote type="cite"><div>On Sep 29, 2015, at 8:40 PM, Yadong Liu &lt;<a href="mailto:yadong@fingerprintplay.com" target="_blank">yadong@fingerprintplay.com</a>&gt; wrote:</div><br><div><div dir="ltr"><div>So
 my question is: what I need to do to make sure the my Objective-C 
object&#39;s dealloc() is called immediately as soon as my JavaScript code 
removes all references to the object?</div></div></div></blockquote><br></div></span><div>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.</div><div><br></div><div>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.</div><div><br></div><div>There may be some other JavaScriptCore experts on the list that can elaborate further.</div><div><br></div><div>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 <a href="http://lists.webkit.org/mailman/listinfo/webkit-help" target="_blank">http://lists.webkit.org/mailman/listinfo/webkit-help</a> and <a href="http://www.lists.apple.com/mailman/listinfo/webkitsdk-dev" target="_blank">http://www.lists.apple.com/mailman/listinfo/webkitsdk-dev</a> — I decided to answer your question here even though it’s off topic. Please see <a href="http://www.webkit.org/contact.html" target="_blank">http://www.webkit.org/contact.html</a> for details.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>— Darin</div></font></span></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>- Yadong<br>Sr. Mobile Engineer<br>Fingerprint Digital Inc.<br><a href="http://www.fingerprintplay.com" target="_blank">http://www.fingerprintplay.com</a><br>1-855-KID-GAME<br><br><span style="background-color:rgb(255,0,0)"><span style="color:rgb(255,0,0)"><b><span style="background-color:rgb(255,255,255)"><a href="http://www.prnewswire.com/news-releases/samsung-and-fingerprint-partner-to-create-mobile-play-and-learn-network-for-kids-companies-launch-initiative-to-drive-app-development-234570981.html" target="_blank">News: Samsung and Fingerprint Announce Kids Mobile Play and Learn Network </a></span></b></span></span><br>
<br><font>Check out our latest apps at </font><font><a href="http://www.fingerprintplay.com/" target="_blank"><span></span></a><font color="#888888"><a href="https://itunes.apple.com/us/artist/fingerprint/id473099999" style="color:rgb(17,85,204)" target="_blank">https://itunes.apple.com/us/artist/fingerprint/id473099999</a></font></font>


<font><br>Like us on Facebook at <a href="https://www.facebook.com/FingerprintPlay" target="_blank">https://www.facebook.com/FingerprintPlay</a></font><br></div></div></div>
</div></div></div>