[PHP-BUG] Bug #60937 [NEW]: Memory leak on unserialize for nested objects
From: Operating system: Debian Linux PHP version: 5.4SVN-2012-01-31 (snap) Package: Performance problem Bug Type: Bug Bug description:Memory leak on unserialize for nested objects Description: Hi, this is a recurring problem in PHP when unserializing large nested objects. When unserializing inside a loop the same serialized object, the total memory consumption increases every couple of iterations. I am attaching the code to replicate it. Have tested it in the latest 5.4 (snap), it also occurs in 5.3. Let me know if you need any more details, Tested on Debian Linux 64 wheezy/sid, however I believe is platform independent. Couldn't find a bug category for serialize/mem leak related issues. Test script: --- https://bugs.php.net/bug.php?id=60937&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60937&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60937&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60937&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60937&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60937&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60937&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60937&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60937&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60937&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60937&r=support Expected behavior: https://bugs.php.net/fix.php?id=60937&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60937&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60937&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60937&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60937&r=php4 Daylight Savings:https://bugs.php.net/fix.php?id=60937&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60937&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60937&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60937&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60937&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60937&r=mysqlcfg
Bug #60937 [Nab]: Memory leak on unserialize for nested objects
Edit report at https://bugs.php.net/bug.php?id=60937&edit=1 ID: 60937 User updated by: npm at nuestrared dot com Reported by: npm at nuestrared dot com Summary:Memory leak on unserialize for nested objects Status: Not a bug Type: Bug Package:Performance problem Operating System: Debian Linux PHP Version:5.4SVN-2012-01-31 (snap) Block user comment: N Private report: N New Comment: Hi, I have updated the object on the script and force the use of gc_collect_cycles() after each iteration. However, there is an increase of 4980736 bytes, after 100 runs, it doesn't happen with every object, but it does with this particular one. Also the increase is not with every iteration but every couple of iterations, until it gets to a maximum, in this case the 4980736 bytes. Let me know if to open a different bug. The updated script at: http://dl.dropbox.com/u/7170408/unserialize_memleak.php The output of the script: Iteration 0 Start Mem 786432 Cicle Mem 3145728 Diff 2359296 Iteration 1 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 2 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 3 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 4 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 5 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 6 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 7 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 8 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 9 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 10 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 11 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 12 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 13 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 14 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 15 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 16 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 17 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 18 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 19 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 20 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 21 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 22 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 23 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 24 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 25 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 26 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 27 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 28 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 29 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 30 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 31 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 32 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 33 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 34 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 35 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 36 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 37 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 38 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 39 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 40 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 41 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 42 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 43 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 44 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 45 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 46 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 47 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 48 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 49 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 50 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 51 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 52 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 53 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 54 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 55 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 56 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 57 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 58 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 59 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 60 Start Mem 786432 Cicle Mem 5767168 Dif
[PHP-BUG] Bug #61014 [NEW]: Memory leak on unserialize for certain nested objects
From: Operating system: Debian Linux PHP version: 5.4SVN-2012-02-08 (snap) Package: Performance problem Bug Type: Bug Bug description:Memory leak on unserialize for certain nested objects Description: Unserializing certain objects on a loop, incurs in increased memory consumption even when the garbage collector is enables and gc_collect_cycles() is called after each iteration. For the test script there is an increase of almost 5MB, after 100 runs, it doesn't happen with every object, but it does with the one on the test. The increase is not with every iteration but every couple of iterations, until it reaches a maximum, in this case the 4980736 bytes. This report is related to bug #60937, I had no reply on my comments. Thanks, Test script: --- The test script can be found at: http://dl.dropbox.com/u/7170408/unserialize_memleak.php Expected result: Consistent memory usage. Actual result: -- The output of the script: Iteration 0 Start Mem 786432 Cicle Mem 3145728 Diff 2359296 Iteration 1 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 2 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 3 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 4 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 5 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 6 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 7 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 8 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 9 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 10 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 11 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 12 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 13 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 14 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 15 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 16 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 17 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 18 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 19 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 20 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 21 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 22 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 23 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 24 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 25 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 26 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 27 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 28 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 29 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 30 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 31 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 32 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 33 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 34 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 35 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 36 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 37 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 38 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 39 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 40 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 41 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 42 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 43 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 44 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 45 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 46 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 47 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 48 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 49 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 50 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 51 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 52 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 53 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 54 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 55 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 56 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 57 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 58 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 59 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 60 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 It
Bug #61014 [Opn]: Memory leak on unserialize for certain nested objects
Edit report at https://bugs.php.net/bug.php?id=61014&edit=1 ID: 61014 User updated by: npm at nuestrared dot com Reported by: npm at nuestrared dot com Summary:Memory leak on unserialize for certain nested objects Status: Open Type: Bug Package:Performance problem Operating System: Debian Linux PHP Version:5.4SVN-2012-02-08 (snap) Block user comment: N Private report: N New Comment: Hi, if you got consistent memory usage, it is probable that your saved string cannot be unserialized correctly, try printing it or turn on PHP errors to see if the unserialize was correct. Previous Comments: [2012-02-08 19:02:59] carloschilazo at gmail dot com I'm not sure the problem is on the unserialize function; I saved the value of $str (after gzuncompress/base64_decode) (so I got the original serialized string, and hardcoded it on the script) Then ran the script and got consistent memory usage... [2012-02-08 16:24:02] npm at nuestrared dot com Description: Unserializing certain objects on a loop, incurs in increased memory consumption even when the garbage collector is enables and gc_collect_cycles() is called after each iteration. For the test script there is an increase of almost 5MB, after 100 runs, it doesn't happen with every object, but it does with the one on the test. The increase is not with every iteration but every couple of iterations, until it reaches a maximum, in this case the 4980736 bytes. This report is related to bug #60937, I had no reply on my comments. Thanks, Test script: --- The test script can be found at: http://dl.dropbox.com/u/7170408/unserialize_memleak.php Expected result: Consistent memory usage. Actual result: -- The output of the script: Iteration 0 Start Mem 786432 Cicle Mem 3145728 Diff 2359296 Iteration 1 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 2 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 3 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 4 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 5 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 6 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 7 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 8 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 9 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 10 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 11 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 12 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 13 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 14 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 15 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 16 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 17 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 18 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 19 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 20 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 21 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 22 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 23 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 24 Start Mem 786432 Cicle Mem 5505024 Diff 4718592 Iteration 25 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 26 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 27 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 28 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 29 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 30 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 31 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 32 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 33 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 34 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 35 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 36 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 37 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 38 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 39 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 40 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 41 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 42 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 43 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 44 Start Mem 786432 Cicle Mem 5767168 Diff 4980736 Iteration 45 Start Me