[Qt-interest] Memory leak converting QScriptValue to QVariant

Stephen Jackson spjackson42 at gmail.com
Wed Aug 19 13:03:50 CEST 2009


On Wed, Aug 19, 2009 at 10:34 AM, Alberto Scarpa wrote:
>
> I found a memory leak on Qt converting QScriptValue to QVariant.
>
> To reproduce it:
> 1. Create a QScriptEngine
> 2. Add an object (SimpleObject) with a QVariant Q_PROPERTY (simpleObjectProperty) to the QScriptEngine
> 3. Set the value of this property via javascript
>
> The javascript code is: while(1) { simpleObject.simpleObjectProperty = 1; }
>
> The leak rises converting the QScriptValue to QVariant inseide the variantFromValue function.
> A QVariant with type -1 is created and in its destructor hadle->clear(&d); is not called (see the following backtrace).
>
> You have the leak with this simple program too:
>
> #include <QVariant>
> int main(int argc, char *argv[])
> {
>    while(1)
>        QVariant v1( -1, (void*)0 );
> }
>
> Any one has a fix?
>

I can confirm that the above code does not leak in Qt 4.4.3 but does
leak in 4.5.1 (same 64-bit linux box). I haven't investigated whether
this has already been reported and/or fixed in a newer version.

-- 
Regards,

Stephen Jackson




More information about the Qt-interest-old mailing list