I have submited a patch to fix this issue: https://codereview.qt-project.org/#/c/141311/
On Mon, Nov 16, 2015 at 11:01 PM, Liang Jian <[email protected]> wrote: > The allocated QV4::QObjectWrapper object hold a QPointer which track > 'instance', it seems that it should be destroyed with > QObjectWrapper::destroyObject() > to properly destruct the QPointer in it in QV4::MemoryManager::sweep(). > But when sweep() is being called it couldn't find the QObjectWrapper > object created before which will make the QPointer in it not destructed > properly. > > On Sun, Nov 15, 2015 at 11:58 PM, Liang Jian <[email protected]> > wrote: > >> After some further investigation I can now confirm that one of the >> leak is caused by the following code in QQmlObjectCreator::createInstance(), >> qqmlobjectcreator.cpp: >> >> *sharedState->allJavaScriptObjects = QV4::QObjectWrapper::wrap(v4, >> instance); >> >> ++sharedState->allJavaScriptObjects; >> >> >> But the reason is still unknown >> >> >> >> On Sun, Nov 15, 2015 at 10:19 PM, Liang Jian <[email protected]> >> wrote: >> >>> 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, >>> /*create*/true); >>> 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, >>> profiler.update(typeRef->component->fileName(), >>> 1053 : context->url(), obj->location.line, >>> obj->location.column)); >>> 1054 : if >>> (typeRef->component->compilationUnit->data->isSingleton()) >>> 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 >>> sharedState->allCreatedObjects.push(instance); >>> 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 >>> QtSharedPointer::ExternalRefCountData >>> 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! >>> >>> >> >
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
