Allowed memory * bytes exhausted in php

I get a "out of memory" error in php. I know this can be fixed with ini_set ("memory_limit", "64M"), but I do not want to do this because the large memory for the script is abnormal. I have several reports that are so huge that I really need this memory, but usually they don’t.

The problem is that I don’t even know which script consumes so much memory, and not a single user (so far) has reported an error. I know this only happens due to log_errors (set to true) and error_log (set to a very noticeable file on my desktop), but it does not tell which script is the culprit.

Any idea on how to know this?

+3
source share
3 answers

You probably have some basic errors of the algorithm, creating large data structures, rebuilding data in the form of other structures, too many large string manipulations, loading entire files into memory, re-fetching data from the storage, and not reusing what was extracted last time, a similar item. And many homegrown database handlers give you the entire dataset returned from your query, rather than providing you with a dataset resource. This is especially dangerous for queries that may return more data than originally intended.

, . , () while( $data = mysql_fetch_assoc() ), foreach( $data_rows as $data ). , .

script. , Apache .

+3

script , 32M, GD, , , . - ( ). .htaccess, :

php_value memory_limit 64M
php_value max_execution_time 30
0

. xdebug. , PHP script.

0

Source: https://habr.com/ru/post/1707726/


All Articles