'Memory leak when using Http facade with Laravel Octane
Does anyone have idea why is memory going up for every request when I'm using Http facade with Laravel Octane ?
Route::get('test', function () {
Http::get('https://swapi.dev/api/people/1');
return memory_get_usage();
});
But when I use Guzzle client like this it's not leaking
Route::get('test', function () {
$client = new \GuzzleHttp\Client();
$client->get('https://swapi.dev/api/people/1');
return memory_get_usage();
});
Solution 1:[1]
class object is not being garbage collected I think.Because its being used somewhere. unset it after you are done with it.
It should free the memory used.
Solution 2:[2]
this is actually a bug in the Laravel HTTP facade because I had encountered the same problem in another context.
Solution 3:[3]
This is the response I've got from official Laravel team member.
https://github.com/laravel/octane/issues/481
The point is that this is not a bug and that it is happening because the garbage collector has not done his thing yet.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amir Daneshkar |
| Solution 2 | hafid id-baha |
| Solution 3 | Osta |


