Hi,
  Recently I encountered a weird issue regarding to JavaScriptCore's garbage
collection mechanism. See following javascript code:

function TestNativeObject(s) {
>   var cb = function() {
>   };
>   cb.call(s);
> }
>
> function Test() {
>   var s = new NativeObject();
>   TestNativeObject(s);
>   s = null;
>   CollectGarbage();
> }
>
> Test();
>

In above code, NativeObject is a class object defined in C++ code, it can
track the lifetime of its instances. CollectGarbage() is a global method
registered from C++ code, which just call JSGarbageCollect() to do garbage
collection forcely. Ideally, the NativeObject created in Test() should be
destroyed when calling CollectGarbage(). But unfortunately, it won't. The
tricky thing is: removing the line "cb.call(s)" in TestNativeObject()
function solves this issue, though cb is just an empty function.

This code was tested against webkit svn. Anyone can help me explain this
behavior? Is it a bug of JavaScriptCore?

Regards
James Su
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to