ZF-5170: Zend_Db_Adapter_Pdo_Mssql memory leak?

Description

Hello,

I have a problem with Zend_Db when using a mssql-database. I'm working several month with Zend Framework now, and was writing a kind of "windows service" in php (with php cli as service or scheduled task). This script runs very long (many days/weeks) in a loop. But I experienced memory problems with Zend_Db.

With each SQL-Query the Zend_Db object seems to grow a bit, depending on the select-result-size!!! Even with only one result row, the script-memory-usage grows. If I do INSERTs or UPDATES, all works fine, but when doing SELECTs, the script-memory-usage grows and grows. And my script runs many days and has 100.000 selects a day, which results in >100MB memory usage growth per day. So I have to restart the script every day ;-(

Zend_Db seems to cache that results or so, I don't know. Zend_Db_Profiler is disabled of cause.

I did a few tests, tested PEAR-MDB2 and also Zend_Db Pdo_Sqlite-Adapter . With these two methods I didn't experience a memory growth.

I will attach my test files, so you can check it on your own. You will need PEAR MDB2 installed to run it (or you disable that part). I will also attach my results (results.txt), where you can see, that sqlite and mdb2 don't grow, but mssql does!

I cannot use Zend_Db with that bug. Please fix it soon!

Michael

Comments

zip archive with my test script and results.txt, where you can see the problem with mssql-adapter

I ran into the same exact issue yesterday. It doesn't seem Zend_Db was written with memory leaks in mind. Running a PHP Daemon using Zend_Db is impossible right now. I am examining the source codes of Zend_Framework right now and will report if I find something.

Someone please fix this!

Well, I think I solved my problem . It was much easier then I thought. My memory kept leaking with when I had the Query Profiler turned on. I turned it off, now memory stopped leaking. Let me know if this solved your issue as well.

Petr