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 leak? #963

Closed
Cluster2a opened this issue Nov 18, 2024 · 2 comments
Closed

Memory leak? #963

Cluster2a opened this issue Nov 18, 2024 · 2 comments

Comments

@Cluster2a
Copy link

Cluster2a commented Nov 18, 2024

Octane Version

2.5.9

Laravel Version

11.32.0

PHP Version

8.3

What server type are you using?

Swoole

Server Version

5.1.5

Database Driver & Version

MySQL 9.1.0

Description

Today, we noticed an increase in memory usage in our app following the latest release. The recent update included some logic adjustments and dependency updates, including Octane and the Laravel framework. We regularly update all dependencies to keep them current.

I tried to identify the source of the memory leak but couldn't pinpoint any specific changes in our logic that might be causing it.

To troubleshoot, I pulled a fresh Laravel codebase (https://github.com/laravel/laravel), added Octane, and checked the memory consumption.

Route::get('/', function () {
    $memoryConsumptionInMB = memory_get_usage() / 1024 / 1024;
    $memoryPeakInMB = memory_get_peak_usage() / 1024 / 1024;
    $memoryLimitInMB = ini_get('memory_limit');
    $memoryLimitInMB = (int) $memoryLimitInMB;

    dd([
        'memory_get_usage' => $memoryConsumptionInMB,
        'memory_get_peak_usage' => $memoryPeakInMB,
        'memory_limit' => $memoryLimitInMB,
    ]);


    return view('welcome');
});

Request number 1:
image

Request number 100:
image

Even with the standard laravel code base the memory seems to increase on every request, which seems odd to me.

I tired to downgrade to swoole 5.1.4, laravel/framework to 11.27.0 and octane 2.5.5 without any luck.

Shouldn't the memory stay the same between two calls (if the same endpoint is being called)?

edit: I now uncommented CollectGarbageand set garbage to 1. Now the memory stays exactly the same.
Do we have an issue here, or is this happening by design?

Best - Alex

Steps To Reproduce

  • setup laravel (default)
  • install octane
  • run server
  • call base endpoint multiple times
@crynobone
Copy link
Member

Wouldn't dd() cause the worker to die and new worker need to be spawned? Would this contribute to additional memory usage?

@Cluster2a
Copy link
Author

I just tested it with a normal response and the memory stays the same - so indeed dd() seems to have an impact.

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

No branches or pull requests

2 participants