Dispose the v8object handle in QQmlData::destroy()
authorChris Adams <christopher.adams@nokia.com>
Fri, 11 May 2012 01:28:24 +0000 (11:28 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 11 May 2012 22:06:33 +0000 (00:06 +0200)
Previously, the handle was simply cleared, which meant that the data
referenced by the handle would only be destroyed during the next
garbage collection cycle.  That had the unwanted side effect that
v8's gc heuristics would assume that the old pointer space needed
expansion more regularly than is required in truth, which has the
further effect of slowing down mark-sweep-compact cycles considerably.

Change-Id: I41595a4d79a75866f434c371139e5493e757d6ab
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
src/qml/qml/qqmlengine.cpp

index f948c31..107e0b5 100644 (file)
@@ -1323,7 +1323,12 @@ void QQmlData::destroyed(QObject *object)
     if (extendedData)
         delete extendedData;
 
-    v8object.Clear(); // The WeakReference handler will clean the actual handle
+    // Dispose the handle.
+    // We don't simply clear it (and wait for next gc cycle to dispose
+    // via the weak qobject reference callback) as this affects the
+    // outcomes of v8's gc statistical analysis heuristics, which can
+    // cause unnecessary growth of the old pointer space js heap area.
+    qPersistentDispose(v8object);
 
     if (ownMemory)
         delete this;