Ticket #95 (assigned defect)
Memory is not free()'d after xcache_get() data is unset
| Reported by: | krogot | Owned by: | moo |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4.0 |
| Component: | cacher | Version: | 1.2-dev |
| Keywords: | Cc: | ||
| Blocked By: | PHP Version: | 5.1.6 | |
| Application: | Need User Feedback: | no | |
| Other Exts: | SAPI: | Irrelevant | |
| Probability: | Blocking: |
Description (last modified by moo) (diff)
I've tested EA vs XCache performance on cache reads and got the following problem:
Code:
<?php function ea_read ($max) # void { global $DATA; for($i = 0;$i<10;$i++) { $key[$i] = 'some_key_'.$i; eaccelerator_put($key[$i], $DATA); } for($i = 0;$i<$max;$i++) $val = eaccelerator_get($key[$i%10]); } function xcache_read ($max) # void { global $DATA; for($i = 0;$i<10;$i++) { $key[$i] = 'some_key_'.$i; xcache_set($key[$i], $DATA); } for($i = 0;$i<$max;$i++) { $val = xcache_get($key[$i%10]); } }
Result ($max = 10000):
<?php $DATA = str_repat('x',10000);
Everything is ok.
<?php $DATA = array_map('uniqid', range(1,10));
Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 15 bytes).
It seems that XCache somehow marks array items that they aren't released (may be it increases ref_count?). I tried to add "unset($val);" after "$val = xcache_get();" but it didn't help.
The only solution I've found is:
<?php xcache_set($key,serialize($data)); $val = unserialize(xcache_get($key));
but it looks weird (and slows down xcache calls) ...
Change History
Note: See
TracTickets for help on using
tickets.

