1

Processwireと呼ばれるCMS/フレームワークでWebサイトを作成していますが、データベースの結果から収集した値(processwireのページと呼ばれる)をいくつかの配列に入力したいと思います。ここで何が起こるかというと、メモリエラーが発生し、メモリ制限を引き上げる必要があることはわかっていますが、ページがどんどん増えていくため、負荷が大きくなり、終了する可能性があるため、正しく感じられません。メモリ制限をさらに増やします。ここで、大きな山からバッチを選択して処理し、次のバッチを選択したいと思います。これがクラッシュの原因となる部分です。

    for($i = 0; $i<=$count_log; $i+=100)
{
    $all_log_files = $pages->find("template=logs, start=$i, limit=100");
    foreach($all_log_files as $log_file)
    {
        $u++;
        if(empty($actions["$log_file->action"]))
        {
            $actions[$log_file->action] = 1;
        }
        if(empty($ips["$log_file->ip"]))
        {
            $ips[$log_file->ip] = 1;
        }
        if(empty($values["$log_file->value"]))
        {
            $values[$log_file->value] = 1;
        }
        if(empty($results["$log_file->result"]))
        {
            $results[$log_file->result] = 1;
        }
    }
}

ご覧のとおり、私はすでに「バッチ」を作成しようとしましたが、それでもエラーが発生するため失敗しました...

これを修正するにはどうすればよいですか、またはできることは何もありません。メモリ制限を上げるだけでよいですか?

編集:

特定のエラー: 致命的なエラー:47行目の/xxx/xxx/xxx/xxx/wire/core/DatabaseQuery.phpで許可されたメモリサイズ33554432バイトが使い果たされました(6バイトを割り当てようとしました)

4

1 に答える 1

3

You're having a memory issue because the data that you're trying to store in memory all at once is too big. You can either increase the memory limit to hold all the data or store less data and change your algorithms to work with batches of the data.

For example, if you have a function that uses the values stored in $results, then you can try to change this function to work just as well with only part of the results, and call the function for each iteration, then empty the array after the iteration finishes.

于 2012-11-27T14:04:36.790 に答える