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 leaks #1703

Open
michael-grunder opened this issue Jan 20, 2020 · 4 comments
Open

Memory leaks #1703

michael-grunder opened this issue Jan 20, 2020 · 4 comments

Comments

@michael-grunder
Copy link
Member

While investigating #1701 it became apparent that PHP wasn't always reporting memory leaks when running the phpredis unit tests, even when PHP was built in debug mode.

When I pulled the logic out of the unit test framework the leaks were again reported, and it was also possible to detect them with USE_ZEND_ALLOC=0 valgrind php script-that-leaks.php.

I'm just creating this issue as a central place to discuss leaks/fixes.

@michael-grunder
Copy link
Member Author

Leak branch here

@yatsukhnenko
Copy link
Member

@michael-grunder have we already merged changes from your branch?

@michael-grunder
Copy link
Member Author

No. The leaks are actually non-trivial to fix. I did get most of them in this branch though.

The good news is that they're pretty obscure/rare and don't likely occur very often.

I can revisit this to see about fixing the last ones I didn't get to yet.

@rqc
Copy link

rqc commented Jan 21, 2021

Hello, first of all thanks for the work on this library, it has really helped us scale our php microservices.

I wanted to report that we are having some issues with memory leaks after integrating in a high traffic production server.

We performed some simple debugging using memory_get_usage() and the delta was several megabytes more than the actual payload that was being processed in the request. We have narrowed down the leak to the usage on a rate limiting function that uses a query like this:

# This is the php-redis client, we are using version 5.3.2
$this->client->cache
                ->multi(Redis::PIPELINE)
                ->hset(self::$BASE_RATE_LIMIT_COUNTER_KEY, $tokens_bucket_key, $this->token_allowance)
                ->hset(self::$BASE_RATE_LIMIT_COUNTER_KEY, $last_reset_key, $now->getTimestamp())
                ->exec();

We are currently using version:

=========================================
Package Version State
redis   5.3.2   stable

It would be great if you could perhaps share if there is a known leak in any of those commands or the use of pipelining.

Thanks!

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

3 participants