[webkit-dev] JavaScriptCore holding onto objects unnecessarily long

Yadong Liu yadong at fingerprintplay.com
Tue Sep 29 22:51:37 PDT 2015


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.

- Yadong

On Tue, Sep 29, 2015 at 10:04 PM, Darin Adler <darin at apple.com> wrote:

> On Sep 29, 2015, at 8:40 PM, Yadong Liu <yadong at 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 and
> 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 for details.
>
> — Darin
>



-- 
- Yadong
Sr. Mobile Engineer
Fingerprint Digital Inc.
http://www.fingerprintplay.com
1-855-KID-GAME

*News: Samsung and Fingerprint Announce Kids Mobile Play and Learn Network
<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>*

Check out our latest apps at <http://www.fingerprintplay.com/>
https://itunes.apple.com/us/artist/fingerprint/id473099999
Like us on Facebook at https://www.facebook.com/FingerprintPlay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20150929/ab5e23ea/attachment.html>


More information about the webkit-dev mailing list