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 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
Iteration 61 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 62 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 63 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 64 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 65 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 66 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 67 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 68 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 69 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 70 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 71 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 72 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 73 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 74 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 75 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 76 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 77 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 78 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 79 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 80 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 81 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 82 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 83 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 84 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 85 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 86 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 87 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 88 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 89 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 90 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 91 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 92 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 93 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 94 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 95 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 96 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 97 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 98 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Iteration 99 Start Mem 786432 Cicle Mem 5767168 Diff 4980736
Done.
Start Mem 786432 End Mem 5767168 Final Diff 4980736
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61014&edit=1