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 #171

Closed
caiking opened this issue Apr 11, 2021 · 6 comments
Closed

memory leak #171

caiking opened this issue Apr 11, 2021 · 6 comments
Assignees
Labels

Comments

@caiking
Copy link

caiking commented Apr 11, 2021

  • Octane Version:0.1.0
  • Laravel Version: 8.36.2
  • PHP Version: 8.0.3
  • Server: Swoole-4.6.5

Description:

i just install laravel,swoole,octane

and start with "php artisan octane:start --port=13000 --watch"

add code like this:

<?php


namespace App\Http\Controllers;


class TestController extends Controller
{
    public function index()
    {
        return memory_get_usage()/1024/1204;
    }
}

and this:

Route::get('/test', App\Http\Controllers\TestController::class."@index");

then did nothing

and i requested "http://127.0.0.1:13000/api/test" in chrome ,often and often

i got these respopnse:
13.533650851329
13.710976432724
13.747858700166
...
15.084081706811
...

The numbers are not going down

@Namoshek
Copy link
Contributor

Try configuring a lower threshold for garbage collection in config/octane.php.

@albertcht
Copy link
Contributor

albertcht commented Apr 12, 2021

Sometimes it's difficult to track memory leak in your Laravel project in long-lived PHP environment. In traditional PHP lifecycle, developers don't need to worry about it because all the resources will be destroyed after each request.

There might be somewhere using global variable wrongly in your project (maybe in other packages). You can try to add max-requests argument when you start the server. And workers will be gracefully restarted after serving that amount of requests to avoid memory leaks.

php artisan octane:start --max-requests=250

@themsaid themsaid self-assigned this Apr 12, 2021
@themsaid
Copy link
Member

Investigating this. Thanks for reporting.

@linaspasv
Copy link

I have experienced the same on a fresh laravel install.

@themsaid
Copy link
Member

fixed here #181

@kocoten1992
Copy link

Hi @themsaid, how you was able detect memory leak?

I got a leak and was trying to find a memory leak detector for swoole, but find none so far.

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

No branches or pull requests

7 participants