[webkit-dev] QtConnectionObjects not cleaned up for QtOwnership objects

2009-12-15 Thread Andrew Webster
For all the Qt people out there, here is my problem:

We have quite a few QObjects that we are inserting into JavaScript
using addToJavaScriptWindowObject, however because we have limited
resources and are creating so many of these objects, we would prefer
that they are NOT ScriptOwnership objects so that there is not as much
duplication for each frame.  This presents a problem when it comes to
using 'connect' to handle signals.  Each connect creates a
QtConnectionObject which references the JSHTMLDocument object.  The
QtConnectionObject is never destroyed because the QObject is never
destroyed, and this prevents most of the objects from being cleaned up
by the gc when the page is refreshed leading to a significant memory
leak.

The solution I'm working on essentially makes the QtConnectionObject
'script owned' so that it is cleaned up when the script is destroyed:

Index: qt_runtime.cpp
===
--- qt_runtime.cpp  (revision 52150)
+++ qt_runtime.cpp  (working copy)
@@ -1527,6 +1527,11 @@
 else {
 // Store connection
 connections.insert(sender, conn);
+// also create a script wrapper for the
connection object, but make sure that it is destroyed when
+// the script goes away
+d-m_instance-rootObject()-gcProtect(
+   QtInstance::getQtInstance(conn,
d-m_instance-rootObject(), QScriptEngine::ScriptOwnership)-
+
createRuntimeObject(exec-dynamicGlobalObject()-globalExec()));
 }
 } else {
 // Now to find our previous connection object. Hmm.

This seems to be working in my limited tests.  Can anyone comment on
the validity of this solution?


Thanks,
Andrew
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] QtConnectionObjects not cleaned up for QtOwnership objects

2009-12-15 Thread Kenneth Christiansen
This should go to the webkit...@lists.webkit.org list instead. Please repost
there.

Creating a bug report on bugs.webkit.org for tracking your issues is another
welcome option.

Kenneth

On Tue, Dec 15, 2009 at 5:24 PM, Andrew Webster apwebs...@gmail.com wrote:

 For all the Qt people out there, here is my problem:

 We have quite a few QObjects that we are inserting into JavaScript
 using addToJavaScriptWindowObject, however because we have limited
 resources and are creating so many of these objects, we would prefer
 that they are NOT ScriptOwnership objects so that there is not as much
 duplication for each frame.  This presents a problem when it comes to
 using 'connect' to handle signals.  Each connect creates a
 QtConnectionObject which references the JSHTMLDocument object.  The
 QtConnectionObject is never destroyed because the QObject is never
 destroyed, and this prevents most of the objects from being cleaned up
 by the gc when the page is refreshed leading to a significant memory
 leak.

 The solution I'm working on essentially makes the QtConnectionObject
 'script owned' so that it is cleaned up when the script is destroyed:

 Index: qt_runtime.cpp
 ===
 --- qt_runtime.cpp  (revision 52150)
 +++ qt_runtime.cpp  (working copy)
 @@ -1527,6 +1527,11 @@
 else {
 // Store connection
 connections.insert(sender, conn);
 +// also create a script wrapper for the
 connection object, but make sure that it is destroyed when
 +// the script goes away
 +d-m_instance-rootObject()-gcProtect(
 +   QtInstance::getQtInstance(conn,
 d-m_instance-rootObject(), QScriptEngine::ScriptOwnership)-
 +
 createRuntimeObject(exec-dynamicGlobalObject()-globalExec()));
 }
 } else {
 // Now to find our previous connection object. Hmm.

 This seems to be working in my limited tests.  Can anyone comment on
 the validity of this solution?


 Thanks,
 Andrew
 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev




-- 
Kenneth Rohde Christiansen
Technical Lead / Senior Software Engineer
Qt Labs Americas, Nokia Technology Institute, INdT
Phone  +55 81 8895 6002 / E-mail kenneth.christiansen at openbossa.org
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev