Memory manager

This class encapsulates memory menagement operations, when PHP works in limited memory mode.

package Default

 Methods

Memory manager constructor

__construct(\Zend\Cache\Storage\StorageInterface $cache = null

If cache is not specified, then memory objects are never swapped

Parameters

$cache

\Zend\Cache\Storage\StorageInterface

Object destructor

__destruct() 

Clean up cache storage

Create new Zend\Memory value container

create(string $value = '') : \Zend\Memory\Container\ContainerInterface

Parameters

$value

string

Exceptions

\Zend\Memory\Exception\ExceptionInterface

Returns

\Zend\Memory\Container\ContainerInterface

Create new Zend\Memory value container, which has value always locked in memory

createLocked(string $value = '') : \Zend\Memory\Container\ContainerInterface

Parameters

$value

string

Exceptions

\Zend\Memory\Exception\ExceptionInterface

Returns

\Zend\Memory\Container\ContainerInterface

Get memory grow limit

getMemoryLimit() : integer

Returns

integer

Get minimum size of values, which may be swapped

getMinSize() : integer

Returns

integer

Set memory grow limit

setMemoryLimit(integer $newLimit) 

Parameters

$newLimit

integer

Set minimum size of values, which may be swapped

setMinSize(integer $newSize) 

Parameters

$newSize

integer

Create new Zend\Memory object

_create(string $value, boolean $locked) : \Zend\Memory\Container\ContainerInterface

Parameters

$value

string

$locked

boolean

Exceptions

\Zend\Memory\Exception\ExceptionInterface

Returns

\Zend\Memory\Container\ContainerInterface

Commit modified object and put it back to the loaded objects list

commit() 

This function is intended to generate unique id, used by memory manager

generateMemManagerId() 

Swap object data to disk Actually swaps data or only unloads it from memory, if object is not changed since last swap

swap(\Zend\Memory\Container\Movable $container, integer $id) 

Parameters

$container

\Zend\Memory\Container\Movable

$id

integer

Check and swap objects if necessary

swapCheck() 

Exceptions

\Zend\Memory\Exception\RuntimeException

 Properties

 

Storage cache object

$cache : \Zend\Cache\Storage\StorageInterface

Default

null
 

Last modified object

$lastModified : \Zend\Memory\Container\Movable

Default

null

It's used to reduce number of calls necessary to trace objects' modifications Modification is not processed by memory manager until we do not switch to another object. So we have to trace only first object modification and do nothing for others

 

Unique memory manager id

$managerId : integer

Default

 

Memory grow limit.

$memoryLimit : integer

Default

-1

Default value is 2/3 of memory_limit php.ini variable Negative value means no limit

 

Overall size of memory, used by values

$memorySize : integer

Default

0
 

Minimum value size to be swapped.

$minSize : integer

Default

16384

Default value is 16K Negative value means that memory objects are never swapped

 

Id for next Zend\Memory object

$nextId : integer

Default

0
 

List of object sizes.

$sizes : array

Default

array()

This list is used to calculate modification of object sizes

array( => , ...)

 

List of candidates to unload

$unloadCandidates : array

Default

array()

It also represents objects access history. Last accessed objects are moved to the end of array

array(

=> , ... )