phpspreadsheet Allowed memory size of xxxxx bytes exhausted

This error could be found in laravel log

[2020-10-07 08:56:19] production.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Allowed memory size of 100663296 bytes exhausted (tried to allocate 20480 bytes) in /var/www/starpoint.gamepp.tw/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Collection/Cells.php:157
Stack trace:
#0 {main}

Solution: Change memory limit in PHP

set_time_limit(1800);
ini_set('memory_limit', '300M');

Reference:

  1. https://www.drupal.org/forum/support/post-installation/2013-02-12/solved-fatal-error-allowed-memory-size-of-33554432-bytes