Edit report at http://bugs.php.net/bug.php?id=51648&edit=1
ID: 51648 User updated by: shooreek at gmail dot com Reported by: shooreek at gmail dot com Summary: Memory leak in infinite loop Status: Open Type: Bug Package: SQLite related Operating System: WinXP SP3 PHP Version: 5.3.2 New Comment: php.ini modifications: -; extension_dir = "ext" + extension_dir = "ext" -;extension=php_sqlite3.dll +extension=php_sqlite3.dll My new test shows that "leak" behaves like caching. It seems to me that SQLite cache entire DB in memory until some limit. Here are the results. First row - date ad time, second - php.exe memory usage (from taskmgr), third - size of DB file. And so on. About 100,000 loops on virtual machine (real machine is to slow with hard disk). As you can see, cache limit, if any, is about 2Mb. 2010.05.25 16.13.32 php.exe 1Â 116 K 75Â 776 mysqlitedb.db --------------- 2010.05.25 16.16.31 php.exe 1Â 512 K 423Â 936 mysqlitedb.db --------------- 2010.05.25 16.19.31 php.exe 1Â 848 K 711Â 680 mysqlitedb.db --------------- 2010.05.25 16.22.30 php.exe 2Â 124 K 961Â 536 mysqlitedb.db --------------- 2010.05.25 16.25.30 php.exe 2Â 380 K 1Â 184Â 768 mysqlitedb.db --------------- 2010.05.25 16.28.29 php.exe 2Â 620 K 1Â 389Â 568 mysqlitedb.db --------------- 2010.05.25 16.31.29 php.exe 2Â 828 K 1Â 575Â 936 mysqlitedb.db --------------- 2010.05.25 16.34.29 php.exe 3Â 028 K 1Â 753Â 088 mysqlitedb.db --------------- 2010.05.25 16.37.29 php.exe 3Â 220 K 1Â 917Â 952 mysqlitedb.db --------------- 2010.05.25 16.40.29 php.exe 3Â 368 K 2Â 070Â 528 mysqlitedb.db --------------- 2010.05.25 16.43.29 php.exe 3Â 368 K 2Â 197Â 504 mysqlitedb.db --------------- 2010.05.25 16.46.30 php.exe 3Â 368 K 2Â 320Â 384 mysqlitedb.db --------------- 2010.05.25 16.49.30 php.exe 3Â 368 K 2Â 437Â 120 mysqlitedb.db --------------- 2010.05.25 16.52.31 php.exe 3Â 368 K 2Â 549Â 760 mysqlitedb.db --------------- 2010.05.25 16.55.32 php.exe 3Â 368 K 2Â 658Â 304 mysqlitedb.db --------------- 2010.05.25 16.58.32 php.exe 3Â 368 K 2Â 763Â 776 mysqlitedb.db --------------- 2010.05.25 17.01.33 php.exe 3Â 368 K 2Â 868Â 224 mysqlitedb.db --------------- 2010.05.25 17.04.33 php.exe 3Â 368 K 2Â 965Â 504 mysqlitedb.db --------------- I found on sqlite.org function sqlite3_soft_heap_limit(int) that limits the amount of heap memory that may be allocated by SQLite. But there is no such function in PHP SQLite extension. So, I don't think that this is a bug. Sorry for the panic :) Previous Comments: ------------------------------------------------------------------------ [2010-05-08 11:22:22] shooreek at gmail dot com Now I cannot provide exact information about modification of php.ini, but I can provide it later (two week's holiday). I modified memory_limit, post_max_size, extension_dir, uncommented some extensions like misql, mysqli, pdo_sqlite, sqlite3, curl. Nothing serious, only extensions from binary VC6 x86 Thread Safe (2010-Mar-04 20:11:08). As you can see, memory leak rate is not so great. You cannot reproduce leak at all, can you? ------------------------------------------------------------------------ [2010-05-07 16:51:42] crrodriguez at opensuse dot org Cannot reproduce in linux, tell us if you have 3rd party extensions installed as well if you have modified php.ini. maybe Pierre can check this one out.. ------------------------------------------------------------------------ [2010-05-07 13:19:50] shooreek at gmail dot com Pakage changed to SQLite related ------------------------------------------------------------------------ [2010-05-04 11:48:26] shooreek at gmail dot com cbandy, you are right: with UPDATE or SELECT queries mem usage remains constant. But with INSERT queries mem usage grows up. I discovered some way to free this memory: you should unlink SQLite DB file and create new one, because $db->close() is _not_ enough! May be there are another ways to do it, but I do not know about their existence. May be someone knows? I think it real bug and it should be fixed. So, it is SQLite extension related bug. There is no such problem in Mysqli. P.S. I first post I wrote that Mysqli have the same problem as SQLite. My fault. The problem was in multiple calls mysqli_init() function. With SELECT, UPDATE, INSERT or UPDATE commands Mysqli do not have memory leaks. If memory leaks related with multiple mysqli_init() calls is a bug, I can report it in separate. Just let me know. Thank you for your attention. ------------------------------------------------------------------------ [2010-05-02 16:24:23] cbandy at jbandy dot com Inserting an infinite number of rows could easily lead to mem usage within SQLite (not PHP). By executing only UPDATE in the loop, DB size should stay constant. Then results should show PHP-SQLite execution leaks. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=51648 -- Edit this bug report at http://bugs.php.net/bug.php?id=51648&edit=1