[webkit-dev] JavaScriptCore holding onto objects unnecessarily long

Yadong Liu yadong at fingerprintplay.com
Tue Sep 29 20:40:08 PDT 2015


Hi,

Our project is using JavaScriptCore to drive application logic and creation
of native UIView hierarchies. A typical use case will involve an
Objective-C class that exposes a number of methods and properties to
JSCore. From the JavaScript side, we create an JSValue object wrapping an
instance of the Objective-C object, and once we are done we remove all
references to it.

One problem we are running into is that the deallocation of the Objective-C
object seems unpredictable, meaning that sometimes the dealloc() method of
said object is invoked immediately, but sometimes it takes up to a couple
of minutes before it would be called. To illustrate the issue, I created
and attached to this email a simple Xcode project. When you run the project
and click the 'Run Script' button (one or multiple times), you can watch
the Xcode debug console for relevant logs and observe when "Person dealloc
- name is bill" would appear.  And btw, my tests were done in Xcode 7 with
iPhone 6 (iOS 9) simulator.

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?

Thanks in advance,

-- 
- 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/d46638e4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JSCoreLeakTest.zip
Type: application/zip
Size: 35770 bytes
Desc: not available
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20150929/d46638e4/attachment.zip>


More information about the webkit-dev mailing list