laravel / reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.
https://reverb.laravel.com
MIT License
1.02k stars 71 forks source link

Memory leak? #145

Closed vatsake closed 4 months ago

vatsake commented 4 months ago

Reverb Version

1.0.0-beta4

Laravel Version

11.0.8

PHP Version

8.2

Description

The memory usage keeps increasing every time events are triggered.

On a test server, I triggered ~20 events, and the memory usage increased by 200kb (and never goes back down).

Reverb memory usage on LIVE server: 11.04 21:40 120MB 12.04 08:40 218MB

I'm using Telescope as well, and yesterday Reverb ran out of memory.

INFO  Starting server on 0.0.0.0:8080 (...).  

   Symfony\Component\ErrorHandler\Error\FatalError 

  Allowed memory size of 268435456 bytes exhausted (tried to allocate 2097160 bytes)

  at vendor/laravel/telescope/src/Telescope.php:329
    325▕         }, static::$tagUsing)));
    326▕ 
    327▕         static::withoutRecording(function () use ($entry) {
    328▕             if (collect(static::$filterUsing)->every->__invoke($entry)) {
  ➜ 329▕                 static::$entriesQueue[] = $entry;
    330▕             }
    331▕ 
    332▕             if (static::$afterRecordingHook) {
    333▕                 call_user_func(static::$afterRecordingHook, new static, $entry);

   Whoops\Exception\ErrorException 

I've tried disabling Telescope, but the memory still grows. So it's not related to Telescope.

Steps To Reproduce

  1. Watch memory usage with for example htop
  2. Trigger some events
driesvints commented 4 months ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!

vatsake commented 4 months ago

I did try the support channel: https://discord.com/channels/297040613688475649/1019646242709569617/threads/1227871334491754506

vatsake commented 4 months ago

I've been spam-sending simple pusher:ping events with postman and the memory is still increasing gradually.

martinbean commented 4 months ago

@driesvints I think this is worthy of being re-opened given you told @vatsake to ask in places like Discord first, but they already had done so.

Also, why point people to places like Discord where there’s no input from Laravel team members? @vatsake has clearly outlined the problem and also steps to reliably reproduce the issue. This is clearly a bug, hence it bringing it to the attention of the Laravel team. This clearly isn’t a “RTFM” or “you’re using it wrong” issue, and is a bug that needs addressing either via a PR or a Laravel team member.

driesvints commented 4 months ago

@martinbean We haven't gotten other reports of this yet. And I've already asked them to re-open an issue with a repo and specific steps so we can reproduce: https://github.com/laravel/reverb/issues/146#issuecomment-2051511058

"Watch memory usage with for example htop & Trigger some events" just isn't a clear way to reproduce sorry. It didn't seem like an actual bug in Reverb to me, hence why I redirected to a support channel. If we can have a repo and a clear way to reproduce then we can have another look.