[webkit-qt] QtConnectionObjects not cleaned up for QtOwnership objects
Kent Hansen
kent.hansen at nokia.com
Mon Jan 18 05:19:58 PST 2010
Hi,
I'd like to see a small, compileable example that shows what issue this
patch is trying to solve, preferably in the form of a test added to the
QWebFrame autotest (WebKit/qt/tests/qwebframe). Such a test is needed in
order to upstream the patch anyway.
The first step would be to file a bug, like Antonio suggests.
Regards,
Kent
ext tonikitoo (Antonio Gomes) skrev:
> It does not look bad to me. I'd say please file a bug, upload your
> patch, and describe how to check the results.
>
> [cc+ Kent] Maybe kent could have an input (?)
>
>
>
>> 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?
>>
>
>
More information about the webkit-qt
mailing list