diff options
author | disconn3ct <[email protected]> | 2021-12-20 23:28:06 +0300 |
---|---|---|
committer | disconn3ct <[email protected]> | 2021-12-20 23:28:06 +0300 |
commit | 39e0fa929a65e268d89b1093fa9dd05f1f9a1ec3 (patch) | |
tree | c80dd2ac52bfe98bf1d566876f5f597b0593f47e | |
parent | 030e7f3fb202c1bd81d59085e0cf4de756d92531 (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.php | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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; } |