I have developed a web application that generates some files using phpSpreadSheet and I have this application in an Ubuntu Server. phpSpreadSheet uses memory of the server to generate this files, but when I generate files like 10 times I get this error:
Fatal error: Out of memory (allocated 72355840) (tried to allocate 20480 bytes) in /var/www/html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php on line 159
I´ve found out that it´s because after files are generated memory of server is still full (image example). Is there any way to clean this memory with PHP?
EDIT: I have found out that if I restart Apache2 memory is cleaned, is there any way on Ubuntu to restart server when memory is full?