Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory exhausted with Laravel 5.5 and Debugbar 3.0 #726

Closed
koichirose opened this issue Sep 14, 2017 · 22 comments
Closed

Memory exhausted with Laravel 5.5 and Debugbar 3.0 #726

koichirose opened this issue Sep 14, 2017 · 22 comments

Comments

@koichirose
Copy link

Full versions:
Laravel 5.5.4
Debugbar 3.0.1

I'm occasionally getting Allowed memory size of 268435456 bytes exhausted (tried to allocate 6295552 bytes). It happened while saving a form, for example.

Reported line of code is the following:
vendor/barryvdh/laravel-debugbar/src/Storage/FilesystemStorage.php:43, link

Everything works if I disable debugbar, of course.

@FelipeeDev
Copy link

FelipeeDev commented Sep 19, 2017

I have the same problem all the time - for now I disable DebugBar.
I notice that it's some infinitive loop. Here is a stack trace (I caught it with memory_get_usage()):

#0 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(354): Illuminate\Database\Eloquent\Model->getDates() #1 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(314): Illuminate\Database\Eloquent\Model->getAttributeValue('alternative_ful...') #2 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1321): Illuminate\Database\Eloquent\Model->getAttribute('alternative_ful...') #3 /fakepath/vendor/entercode/auth/src/User.php(211): Illuminate\Database\Eloquent\Model->__get('alternative_ful...') #4 /fakepath/vendor/entercode/auth/src/User.php(226): EnterCode\Auth\User->getFullName() #5 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(439): EnterCode\Auth\User->getFullNameAttribute(NULL) #6 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(451): Illuminate\Database\Eloquent\Model->mutateAttribute('full_name', NULL) #7 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(110): Illuminate\Database\Eloquent\Model->mutateAttributeForArray('full_name', NULL) #8 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(920): Illuminate\Database\Eloquent\Model->attributesToArray() #9 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(238): Illuminate\Database\Eloquent\Model->toArray() #10 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(920):
(...)
/fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(920): Illuminate\Database\Eloquent\Model->relationsToArray() #1889 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(238): Illuminate\Database\Eloquent\Model->toArray() #1890 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(920): Illuminate\Database\Eloquent\Model->relationsToArray() #1891 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(238): Illuminate\Database\Eloquent\Model->toArray() #1892 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(920): Illuminate\Database\Eloquent\Model->relationsToArray() #1893 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(238): Illuminate\Database\Eloquent\Model->toArray() #1894 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(920): Illuminate\Database\Eloquent\Model->relationsToArray() #1895 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(238): Illuminate\Database\Eloquent\Model->toArray() #1896 /fakepath/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(920): Illuminate\Database\Eloquent\Model->relationsToArray() #1897 /fakepath/vendor/barryvdh/laravel-debugbar/src/DataCollector/MultiAuthCollector.php(128): Illuminate\Database\Eloquent\Model->toArray() #1898 /fakepath/vendor/barryvdh/laravel-debugbar/src/DataCollector/MultiAuthCollector.php(60): Barryvdh\Debugbar\DataCollector\MultiAuthCollector->getUserInformation(Object(EnterCode\Auth\User)) #1899 /fakepath/vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(811): Barryvdh\Debugbar\DataCollector\MultiAuthCollector->collect() #1900 /fakepath/vendor/maximebf/debugbar/src/DebugBar/DebugBar.php(265): Barryvdh\Debugbar\LaravelDebugbar->collect() #1901 /fakepath/vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php(991): DebugBar\DebugBar->getData() #1902 /fakepath/vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(847): DebugBar\JavascriptRenderer->render() #1903 /fakepath/vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php(732): Barryvdh\Debugbar\LaravelDebugbar->injectDebugbar(Object(Illuminate\Http\Response)) #1904 /fakepath/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(74): Barryvdh\Debugbar\LaravelDebugbar->modifyResponse(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response)) #1905 /fakepath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure)) #1906 /fakepath/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #1907 /fakepath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request)) #1908 /fakepath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #1909 /fakepath/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #1910 /fakepath/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request)) #1911 /fakepath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #1912 /fakepath/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #1913 /fakepath/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #1914 {main}

@DKarakis
Copy link

#750

@barryvdh
Copy link
Owner

Does this also happen without debugbar? Can you try to disable options from the query collector, like replacing params and backtrace?

@SlyDave
Copy link

SlyDave commented Jan 4, 2018

Hey @barryvdh, We're getting this too.

It doesn't happen if I disable debugbar via APP_DEBUG=false in .evn

We don't get any stack trace, just a fatal php error, which appears to vary between 3 locations, but all related to debug/caching

[04-Jan-2018 12:44:08 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/david/Projects/sentry-defence/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 122
[04-Jan-2018 12:44:20 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/david/Projects/sentry-defence/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php on line 187
[04-Jan-2018 12:44:20 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Users/david/Projects/sentry-defence/vendor/symfony/debug/Exception/FatalErrorException.php on line 1
[04-Jan-2018 12:45:16 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in /Users/david/Projects/sentry-defence/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php on line 187
[04-Jan-2018 12:45:48 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/david/Projects/sentry-defence/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php on line 187
[04-Jan-2018 12:45:48 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Users/david/Projects/sentry-defence/vendor/symfony/debug/Exception/FatalErrorException.php on line 1
[04-Jan-2018 12:46:32 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 274432 bytes) in /Users/david/Projects/sentry-defence/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php on line 187
[04-Jan-2018 12:46:32 UTC] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /Users/david/Projects/sentry-defence/vendor/symfony/debug/Exception/FatalErrorException.php on line 1

Laravel 5.5.26
Debugbar 3.1.0

We're not doing anything fancy, have a resource controller with a post action to create() which is using doing things like view('foo')->with('object', $object)

The object in our case is a standard Eloquent model, which has a few relationships.

We've had to disable debugbar in our project for now :(

@SlyDave
Copy link

SlyDave commented Jan 9, 2018

We managed to find out what was causing our problem, usage of another package that when being included in the stacktrace for display in debugbar was pulling in a ton of data from it's flat json database.

resolving that resolved debugar crashing out on us

@a-ghasemi
Copy link

Same Issue on Laravel 5.5.32
I downgraded Debugbar to 2.4.3 but not solved

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)

any solution?

@samfrjn11
Copy link

I just had the following error:
"192.168.1.20:50283 [500]: / - Allowed memory size of 134217728 bytes exhausted (tried to allocate 212992 bytes) in /Users/samsmekens/GitHub/tempproject/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 38"

I found really NO way why I suddenly got this error ALL the time (couldn't access my application anymore).

I tried to clear my cache, but this didn't work. The error obviously had something to do with the app trying to load a file that was too big. So I started to check my log files. I started by deleting the directory "debugbar" under my storage directory. This immediately fixed the issue.

App running Laravel 5.4.36 with debugbar 2.4.3.

@petrmach
Copy link

I am having the same issue, turns out that in my it's caused by @can or Gate::allows calls.

Conditions:

  • DEBUG enabled
  • iteration over multiple entities (e.g. DataTable etc)
  • calls to @can or Gate::allows

The Policy logic itself doesn't seem to matter - I get this error even when simply returning true.

Laravel 5.5.34 / debugbar v3.1.1

@KazakovVS
Copy link

The same behaviour for me. On often Gate::allows calls, the server returns 500
"Allowed memory size of 134217728 bytes exhausted (tried to allocate 360448 bytes)"

Conditions:

  1. DEBUG enabled
  2. calls Gate::allows

class: "Symfony\Component\Debug\Exception\FatalErrorException"
file: ".../vendor/predis/predis/src/Connection/StreamConnection.php"
line: 345

Laravel 5.4.36 / debugbar v2.4.3

@mkantautas
Copy link

mkantautas commented May 7, 2018

Symfony\Component\Debug\Exception\FatalErrorException thrown with message "Allowed memory size of 536870912 bytes exhausted (tried to allocate 132278680 bytes)"

Stacktrace:
#0 Symfony\Component\Debug\Exception\FatalErrorException in /home/app/vendor/maximebf/debugbar/src/DebugBar/JavascriptRenderer.php:986

On Laravel 5.6 as well

@vikashsp
Copy link

vikashsp commented Oct 4, 2018

deleting everything in my '\storage\debugbar' is what worked for me! Thanks so much!!!

This worked for me

@tristar500
Copy link

deleting everything in my '\storage\debugbar' is what worked for me! Thanks so much!!!

This worked for me

Same here.

@vencendor
Copy link

php artisan debugbar:clear

@nekromoff
Copy link

Still hapenning, latest Laravel... Maybe debug bar shouldn't process large objects over xxxx MB

@nekromoff
Copy link

Clearing storage works only temporarily for one reload as the next reload throws the same error.

@skalero01
Copy link

This happens on laravel 5.8 too :/

@frutality
Copy link

Happening only when application throws an exception. But stacktrace shows that problem occurs at maximebf/debugbar/src/DebugBar/DataCollector/ExceptionsCollector.php:42, so not sure if this is related to laravel-debugbar or just debugbar.

Exactly in method addThrowable, line $this->exceptions[] = $e;. Hope this helps.

@connor11528
Copy link

connor11528 commented May 6, 2020

  • Delete the files in ./storage/debugbar
  • If using Vagrant you can edit /etc/php/7.2/cli/php.ini so that you have more memory:
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 4096M

@stale
Copy link

stale bot commented Jul 29, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.

@stale stale bot added the stale label Jul 29, 2020
@stale stale bot closed this as completed Aug 5, 2020
@kdescoubes
Copy link

Hi,

Same problem here with Laravel 7.16.1 and debugbar 3.3.3.
Using php 7.4.10 with FPM, and Apache 2.4.38

[Fri Sep 25 15:45:33.069651 2020] [proxy_fcgi:error] [pid 5446] [client 92.152.109.182:58170] AH01071: Got error 'PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 27267072 bytes) in /home/project/dev/vendor/barryvdh/laravel-debugbar/src/Storage/FilesystemStorage.php on line 43', referer: https://project.local/chantiers

@petrknap
Copy link

Hi, same problem with Laravel 10.34.2 and debugbar 3.13.5. It contains infinite loop around vendor/barryvdh/laravel-debugbar/src/LaravelDebugbar.php:268 - in my case it usually occurs when translation is missing.

[2024-06-13 09:09:41] local.WARNING: A possible infinite logging loop was detected and aborted. It appears some of your handler code is triggering logging, see the previous log record for a hint as to what may be the cause.

@parallels999
Copy link
Contributor

Feel free to open a PR with the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests