Document percieved memory leak
authorAlan Alpert <aalpert@blackberry.com>
Mon, 1 Apr 2013 18:07:18 +0000 (11:07 -0700)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 1 May 2013 17:53:51 +0000 (19:53 +0200)
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>
src/qml/qml/qqmlengine.cpp
src/qml/qml/v8/qjsengine.cpp

index 5fa5cfd..1c3aff6 100644 (file)
@@ -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()
 {
index 5b1464a..dbd0851 100644 (file)
@@ -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()
 {