diff options
author | Alan Alpert <aalpert@blackberry.com> | 2013-04-01 11:07:18 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-01 19:53:51 +0200 |
commit | 329a3462903c60876be3449c82d0bc16b72bf402 (patch) | |
tree | d88f44a9433f9ee659e0af02c5b7619edcecd50c /src | |
parent | d88f6f2345c2a2c7f93ebf73ac9a90edad0c9979 (diff) |
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 <chris.adams@jollamobile.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qjsengine.cpp | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5fa5cfd9ef..1c3aff6892 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 5b1464afe6..dbd0851fec 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() { |