Adding some garbage collection calls, a=chris

Chris Pollett [2021-10-15 21:Oct:th]
Adding some garbage collection calls, a=chris
Filename
src/executables/QueueServer.php
src/library/IndexDocumentBundle.php
src/library/Utility.php
diff --git a/src/executables/QueueServer.php b/src/executables/QueueServer.php
index 1b497f9d7..50c671f86 100755
--- a/src/executables/QueueServer.php
+++ b/src/executables/QueueServer.php
@@ -1891,6 +1891,7 @@ class QueueServer implements CrawlConstants
         L\crawlLog("Indexer checking if archive partition and advanced: ".
             L\changeInMicrotime($start_total_time));
         $this->index_archive->updateDictionary();
+        L\garbageCollect();
     }
     /**
      * Checks how old the oldest robot data is and dumps if older then a
diff --git a/src/library/IndexDocumentBundle.php b/src/library/IndexDocumentBundle.php
index 1364f138c..2fcb4016d 100644
--- a/src/library/IndexDocumentBundle.php
+++ b/src/library/IndexDocumentBundle.php
@@ -292,9 +292,9 @@ class IndexDocumentBundle implements CrawlConstants
             // Save current shard dictionary to main dictionary
             measureCall($this, "buildInvertedIndexPartition",
                 [$next_partition, $taking_too_long_touch]);
-            measureCall($this, "addPartitionPostingsDictionary",
-                [$next_partition, $taking_too_long_touch]);
             $num_freed = garbageCollect();
+            $this->addPartitionPostingsDictionary(
+                $next_partition, $taking_too_long_touch);
             crawlLog("Indexer force running garbage collector after partition".
                  " advance. This freed $num_freed bytes.");
             $after_usage = memory_get_usage();
@@ -682,12 +682,9 @@ class IndexDocumentBundle implements CrawlConstants
             ];
             return $statistics;
         }
-        measureCall($doc_map_tools, "save", [$doc_map_filename, $doc_map],
-            "doc_map_tools_save");
-        measureCall($postings_tools, "save", [$postings_filename, $postings],
-            "postings_tools_save");
-        measureCall($last_entries_tools, "save", [$last_entries_filename,
-            $last_entries], "last_entries_tools_save");
+        $doc_map_tools->save($doc_map_filename, $doc_map);
+        $postings_tools->save($postings_filename, $postings);
+        $last_entries_tools->save($last_entries_filename, $last_entries);
         crawlLog("  Indexer build inverted index time ".
             changeInMicrotime($start_time));
         return true;
diff --git a/src/library/Utility.php b/src/library/Utility.php
index 7197652cc..e4f2f910a 100755
--- a/src/library/Utility.php
+++ b/src/library/Utility.php
@@ -2418,10 +2418,12 @@ function measureCall($object, $method, $arguments = [], $call_name = "")
     $before_memory = memory_get_usage();
     $start_time = microtime(true);
     $result = call_user_func_array([$object, $method], $arguments);
+    garbageCollect();
     $after_memory = memory_get_usage();
     $result_clone = variableClone($result);
     $delta_clone_memory = memory_get_usage() - $after_memory;
     unset($result_clone);
+    garbageCollect();
     $delta_memory = $after_memory - $delta_clone_memory - $before_memory;
     $method_stat["MEMORY_NOT_RETURNED"] += $delta_memory;
     $method_stat["TIME_SPENT"] = changeInMicrotime($start_time);
ViewGit