From: Alan Alpert Date: Mon, 1 Apr 2013 18:07:18 +0000 (-0700) Subject: Document percieved memory leak X-Git-Tag: upstream/5.2.1~798^2~95 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=329a3462903c60876be3449c82d0bc16b72bf402;p=platform%2Fupstream%2Fqtdeclarative.git Document percieved memory leak QJSEngine doesn't call collectGarbage upon deletion, because this operation can be expensive and in most cases the JS engine is deleted during application shutdown, when the memory can be deallocated cheaper. This can lead to an apparent memory leak if multiple engines are created and destroyed in the same process. Documenting how to avoid this. Change-Id: Ie02cb8bedc8821e0bb04dfa52a5a2d65b4b085a3 Reviewed-by: Christopher Adams --- diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5fa5cfd..1c3aff6 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -831,6 +831,8 @@ QQmlEngine::QQmlEngine(QQmlEnginePrivate &dd, QObject *parent) Any QQmlContext's created on this engine will be invalidated, but not destroyed (unless they are parented to the QQmlEngine object). + + See QJSEngine docs for details on cleaning up the JS engine. */ QQmlEngine::~QQmlEngine() { diff --git a/src/qml/qml/v8/qjsengine.cpp b/src/qml/qml/v8/qjsengine.cpp index 5b1464a..dbd0851 100644 --- a/src/qml/qml/v8/qjsengine.cpp +++ b/src/qml/qml/v8/qjsengine.cpp @@ -195,6 +195,10 @@ QJSEngine::QJSEngine(QJSEnginePrivate &dd, QObject *parent) /*! Destroys this QJSEngine. + + Garbage is not collected from the persistent JS heap during QJSEngine + destruction. If you need all memory freed, call collectGarbage manually + right before destroying the QJSEngine. */ QJSEngine::~QJSEngine() {