Opened 11 years ago

Last modified 4 years ago

#95 assigned defect

Memory is not free()'d — at Version 1

Reported by: krogot Owned by: moo
Priority: major Milestone: 3.3.0
Component: cacher Version: 1.2.2
Keywords: Cc: mat999@…
Application: PHP Version: 5.1.6
Other Exts: SAPI: Irrelevant
Probability: Always Blocked By:
Blocking:

Description (last modified by moo)

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 (1)

comment:1 Changed 11 years ago by moo

  • Description modified (diff)
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.