-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Labels
Description
Like the title says, I ran into a discussion about some memory leaks for beyondcode/laravel-websockets here: beyondcode/laravel-websockets#325
The basic truth is that after some testing, I found out that running broadcast(...)
will severely increase the memory for a ReactPHP loop, for instance.
To replicate this:
- create a new Laravel project
composer require laravel/websockets:"dev-2.x-memory-leak"
- copy the migrations:
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="migrations"
- run them:
php artisan migrate
- get to the root of the project and run
php artisan websockets:serve --statistics-interval=1
- open an artisan server with
php artisan serve
- Go to
http://127.0.0.1:8000/laravel-websockets
- Click on Connect
- Watch the memory increase in the console that ran
websockets:serve
As explained in beyondcode/laravel-websockets#325 (comment) and beyondcode/laravel-websockets#325 (comment), the problem starts from a broadcast()
that causes the leakage.
I have tested even the code within the event. Running broadcast()
caused the memory leaks.
allcaretravels and ShahanaAlamAntoradeepchrish