[Development] [Qt-5.6] leak of QtSharedPointer::ExternalRefCountData objects

Liang Jian jianliang79 at gmail.com
Sun Nov 15 15:19:48 CET 2015

      Hello everyone, I checkout qt 5.6 branch yesterday in my windows 10
x64 machine, I build it and run my program and see many leaks. Then I use C++
Memory Validator to find the source of the leaks, I can now confirm the
leaked objects are QtSharedPointer::ExternalRefCountData which are created
in QQmlObjectCreator::createInstance(), qqmlobjectcreator.cpp Line 1049,
below is the call stack printed by C++ Memory Validator:

   Qt5Cored.dll  QtSharedPointer::ExternalRefCountData::getAndRef :
[d:\qt5\qtbase\src\corelib\tools\qsharedpointer.cpp Line 1337]

   Qt5Qmld.dll  QWeakPointer<QObject>::QWeakPointer<QObject><QObject> :
[d:\qt5\qtbase\src\corelib\tools\qsharedpointer_impl.h Line 706]

   Qt5Qmld.dll  QPointer<QObject>::QPointer<QObject> :
[d:\qt5\qtbase\src\corelib\kernel\qpointer.h Line 65]

   Qt5Qmld.dll  QQmlObjectCreator::createInstance :
[d:\qt5\qtdeclarative\src\qml\qml\qqmlobjectcreator.cpp Line 1049]
    1044 :                 QQmlData *ddata = QQmlData::get(instance,
    1045 :                 ddata->rootObjectInCreation = true;
    1046 :                 sharedState->rootContext->isRootObjectInCreation
= false;
    1047 :             }
    1048 :
    1049 :             sharedState->allCreatedObjects.push(instance);
    1050 :         } else {
    1051 :             Q_ASSERT(typeRef->component);
    1052 :             Q_QML_OC_PROFILE(sharedState->profiler,
    1053 :                     context->url(), obj->location.line,
    1054 :             if
   Qt5Qmld.dll  QQmlObjectCreator::create :
[d:\qt5\qtdeclarative\src\qml\qml\qqmlobjectcreator.cpp Line 197]

   Qt5Qmld.dll  QQmlComponentPrivate::beginCreate :
[d:\qt5\qtdeclarative\src\qml\qml\qqmlcomponent.cpp Line 863]

   Qt5Qmld.dll  QQmlComponent::beginCreate :
[d:\qt5\qtdeclarative\src\qml\qml\qqmlcomponent.cpp Line 812]

   Qt5Qmld.dll  QQmlComponent::create :
[d:\qt5\qtdeclarative\src\qml\qml\qqmlcomponent.cpp Line 772]

   Qt5Quickd.dll  QQuickView::continueExecute :
[d:\qt5\qtdeclarative\src\quick\items\qquickview.cpp Line 486]

   Qt5Quickd.dll  QQuickViewPrivate::execute :
[d:\qt5\qtdeclarative\src\quick\items\qquickview.cpp Line 127]

   Qt5Quickd.dll  QQuickView::setSource :
[d:\qt5\qtdeclarative\src\quick\items\qquickview.cpp Line 256]

    All the leaked QtSharedPointer::ExternalRefCountData objects are
allocated in the line
    then some other code path will also use QPointer (contained in some
structures allocated by v4mm) to track the same object 'instance' and I
guess the QPointer wasn't properly destructed which will cause the
not deleted.
    I have investigated this issue for nearly one day, but I can't find
which code cause the leak, this is a non-trivial leak, I hope somebody can
help to find the source of the leak. thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20151115/e21b3201/attachment.html>

More information about the Development mailing list