Files (songs) are uploaded to the site, while the file (contents) is saved to the database (such were the requirements for the files in the database to be saved). The field where the content is saved is of type "mediumblob". Everything is working fine.

But when you try to download a file that weighs 70MB, you get an error:

"Fatal error: llowed memory size of 268435456 bytes exhausted (tried to allocate 154488859 bytes) in /home/admin/web/mysite.com/public_html/library/Zend/Db/Statement/Pdo.php on line 228"

228 line: return $this->_stmt->execute($params);
That is, when you try to perform a query to the database.

Tried to manipulate the "memory_limit" parameter. Put different values ​​256M, 512M, 1G, 3072M, but the situation remained the same.

According to the sysadmin who worked with the server and set it up, the server has 16GB of RAM. That is, in fact, it should be enough for him.

How can you more or less determine in detail the cause of the error in order to know what and how to set up to fix it?

Thank.

  • > Tried to manipulate the "memory_limit" parameter. Put different values ​​256M, 512M, 1G, 3072M, but the situation remained the same. In runtime, or what? > But when you try to download a file that weighs 70 MB A copy of the file in memory + a copy of the transferred data is already 140 MB, apparently two more copies somewhere are formed. - etki
  • Well, in terms of what I changed the parameter in .htaccess and repeatedly tried to load the file. - walik
  • @walik what setup is generally used? mod_php or php-fpm? - etki
  • I honestly don’t know exactly how to know exactly what is being used? It seems to me that mod_php. - walik
  • @walik, in general, in some cases, the amount of allocated memory can be changed only from the config. In your case, I would try not to optimize the code for now, but try to edit the config (it will be stupidly cheaper in terms of costs). - etki

1 answer 1

Try setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY parameter in PDO::MYSQL_ATTR_USE_BUFFERED_QUERY

  • I tried this: $ stmt = $ this-> pdo-> prepare ('SQL', array (PDO :: MYSQL_ATTR_USE_BUFFERED_QUERY => true)); It did not help, anyway the error. - walik