Reviewed by Geoff.
[WebKit-https.git] / JavaScriptCore / kjs / collector.cpp
index 5ba3b6284d97469f36054594af300783deb01fc8..8deeb15b1072573f01553954d5dff6f69cf06597 100644 (file)
@@ -116,7 +116,9 @@ void* Collector::allocate(size_t s)
 
   // collect if needed
   size_t numLiveObjects = heap.numLiveObjects;
-  if (numLiveObjects - heap.numLiveObjectsAtLastCollect >= ALLOCATIONS_PER_COLLECTION) {
+  size_t numLiveObjectsAtLastCollect = heap.numLiveObjectsAtLastCollect;
+  size_t numNewObjects = numLiveObjects - numLiveObjectsAtLastCollect;
+  if (numNewObjects >= ALLOCATIONS_PER_COLLECTION && numNewObjects >= numLiveObjectsAtLastCollect) {
     collect();
     numLiveObjects = heap.numLiveObjects;
   }