Opened 11 years ago

Last modified 5 years ago

#95 assigned defect

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

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

I've tested EA vs XCache performance on cache reads and got the following problem:

Code:

	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):

    $DATA = str_repat('x',10000); 

Everything is ok.

    $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:

   xcache_set($key,serialize($data));
   $val = unserialize(xcache_get($key));

but it looks weird (and slows down xcache calls) ...

Change History (0)

Note: See TracTickets for help on using tickets.