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 Log #1742

Closed
ghost opened this issue Dec 27, 2013 · 4 comments
Closed

Memory Leak Log #1742

ghost opened this issue Dec 27, 2013 · 4 comments
Labels
bug A bug report status: medium Medium

Comments

@ghost
Copy link

ghost commented Dec 27, 2013

I have some code that I use the logger, in this case specifically the FileAdapter logger. When I run the code using logger->begin() & logger->commit, the script runs out of memory (code is inserting ~1gb of data into db and generates roughly 1gb of logging info. Of course I do not log all 1gb in a transaction - it should be spread over ~100k transcations).

Code is at: https://gist.github.com/anonymous/8145276.

When I run the same code, commenting only logger->begin & commit calls, the script does not run out of memory. So basically, code with lines 120, 126 commented out runs, but uncommented runs out of memory pretty quickly (out of 1.6m records to insert, 17k are).

I'm using the 32 bit phalcon .dll on a windows machine.

I remember there used to be a guide to getting started on understanding phalcon C code which I attempted to find so I could look at source, but unfortunately I cannot find that now, but it seems to me the queue that stores transcation log messages is never freed?

I can post code

@phalcon
Copy link
Collaborator

phalcon commented Dec 27, 2013

A memory leak means that PHP or an extension is using memory and is losing any reference to those data avoiding that these allocated memory could be released before.

In this case, a transaction in the logger, keeps the messages in memory instead of flushing them one by one. If you want to use transactions you need that memory available for PHP in order to temporary store those data in memory.

@ghost
Copy link
Author

ghost commented Dec 27, 2013

Oh doh! I'm sorry. I never thought that a single logger transaction would be too large to fit in memory for some reason. I'll test again once I have the chance. I had just assumed that every transaction would be able to fit into memory, and so running out of memory meant the log transcation was not being flushed after a commit() call.

If I increase the memory limit to some size that is greater then any single transaction could be, and the code STILL crashes, would that imply that there could be a memory leak?

Thanks!

@ghost
Copy link
Author

ghost commented Dec 30, 2013

I think the issue is that Phalcon\Logger\Adapter::commit() does not clear the queue.

@ghost
Copy link
Author

ghost commented Jan 1, 2014

So I tested on my not updated dll and the test case doesn't work (i.e. it's 2 in both cases). Will an updated dll be posted or do I need to switch to linux and build from source?

@ghost ghost mentioned this issue Jan 4, 2014
@niden niden closed this as completed Jan 16, 2014
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

1 participant