1

I have User_controller and there is function user_details, this function returns view name user_details.

This view contains number of details, generally there will be 10 to 15 sets(row) of details which display on page(details comes from database using user_details table).

It's working fine but in some case when user details goes to 30 to 35 sets(row), i am getting below error in error_log file

PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 5896720 bytes) in /laravel/framework/src/Illuminate/View/Engines/PhpEngine.php on line 63 PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 6414336 bytes) in /vendor/symfony/http-foundation/Response.php on line 1235

Above error return at below line:

return view('admin.views.user_details', ['user' => $user[0]
         , 'user_details' => $user_details);
shaedrich
  • 5,457
  • 3
  • 26
  • 42
Sunil Dabhi
  • 99
  • 2
  • 13
  • 3
    Increase your memory limit in php.ini, ~32mb is rather low value i'd suggest setting at least 128mb. – biesior Apr 08 '21 at 13:55
  • 1
    Does this answer your question? [Allowed memory size of 536870912 bytes exhausted in Laravel](https://stackoverflow.com/questions/34864524/allowed-memory-size-of-536870912-bytes-exhausted-in-laravel) – biesior Apr 08 '21 at 13:57
  • i don't have server access so i can't modify anything on server, is that any other way like changing in laravel files to reduce memory usage? – Sunil Dabhi Apr 09 '21 at 05:21
  • It's recommendable to check _why_ the script takes so much memory. Most of the time, this is unwanted behavior and therefore the script should be changed instead of the memory limit. – shaedrich Apr 09 '21 at 07:50
  • 1
    In your UserController, show us the complete `user_details()` method. It looks like you are loading too much data from the database (hint: `$user[0]`) filling memory and crashes in blade rendering. – Dimitri Mostrey Apr 10 '21 at 07:04

4 Answers4

0

You can set the memory size anything you need:

ini_set('memory_limit', '64M');` 

Before doing anything like this you should check real issue first. Try to prevent it if possible.

olibiaz
  • 2,551
  • 4
  • 29
  • 31
0

you need to open < php.ini > file. find this line :

memory_limit

then change number beside equal to anything you want. for example:

memory_limit = 256M

⚠️NOT RECOMANDED⚠️ you can also edit .htaccess file and add/edit this line

php_value memory_limit 256M

thats all

0

check memory_limit=-1 in cpanel

enter image description here

OmidDarvishi
  • 558
  • 4
  • 8
-2
  1. Open Cpanel,
  2. Check for MultiPHP INI Editor,
  3. then select your website, then check for for memory_limit
  4. Set to -1

works for me..thank you

shine odigie
  • 156
  • 1
  • 6
  • 1
    How this answer is different from the [existing one](https://stackoverflow.com/questions/67005429/fatal-error-allowed-memory-size-of-33554432-bytes-exhausted-laravel-8/73002814#68879147)? – Your Common Sense Jul 16 '22 at 08:50
  • 2
    What makes you think that the OP uses cPanel after all? – Nico Haase Jul 16 '22 at 08:52