Storage::disk('local')->append() で out of memory
正確には何度も繰り返しappend()していたらout of memoryとなりました。
原因は少し前のissueになりますが、githubにありました
Storage::disk('local')->append method run out of memory #24439
issueによるとライブラリの関係でappendを呼ぶ度に、ファイルの中身をメモリに読み込んでいるのが原因のようです。
対応
これはローカルファイルに書き込む場合に起きるのでLaravel使わずにやります。
example.php
$handle = fopen(storage_path("app/hoge.csv"), "a"); // aで追記モード
fwrite($handle, ",");
fclose($handle);
むちゃくちゃ簡単な対応ではあるのですが、メモリが足りない理由がどこかはっきりわからないのでしばらく困ってしまいました。
書き込むデータが大きいのが原因のようにも見えてしまうのですが、フレームワーク側の問題でした。