summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordisconn3ct <[email protected]>2021-12-20 23:28:06 +0300
committerdisconn3ct <[email protected]>2021-12-20 23:28:06 +0300
commit39e0fa929a65e268d89b1093fa9dd05f1f9a1ec3 (patch)
treec80dd2ac52bfe98bf1d566876f5f597b0593f47e
parent030e7f3fb202c1bd81d59085e0cf4de756d92531 (diff)
fix: lower memory use
Flush the stream to disk at each batch to prevent memory exhaustion. (According to random stack overflow, but it did solve my issues.)
-rw-r--r--init.php11
1 files changed, 11 insertions, 0 deletions
diff --git a/init.php b/init.php
index 4d17845..78661ec 100644
--- a/init.php
+++ b/init.php
@@ -173,6 +173,17 @@ class Data_Migration extends Plugin {
$zip->addFromString($batch_filename, json_encode($batch));
+ // flush all that used memory
+ if ($zip->close() !== TRUE) {
+ Debug::log("write error while saving data to $output_file");
+ exit(3);
+ }
+ $zip = new ZipArchive();
+
+ if ($zip->open($output_file) !== TRUE) {
+ Debug::log("unable to reopen $output_file");
+ exit(3);
+ }
if (count($batch["articles"]) != $batch_size)
break;
}