Memory manager

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

 Methods

Memory manager constructor

__construct(\Zend\Cache\Storage\StorageInterface $cache) 

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

Parameters

Object destructor

__destruct() 

Clean up cache storage

Create new Zend_Memory value container

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

Create new Zend_Memory value container, which has value always locked in memory

createLocked(string $value) : \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

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

_commit() 

Create new Zend_Memory object

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

Parameters

$value

string

$locked

bool

Exceptions

\Zend\Memory\Exception\ExceptionInterface

Returns

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

$id

integer

Check and swap objects if necessary

_swapCheck() 

 Properties

 

Storage cache object

$cache : \Zend\Cache\Storage\StorageInterface

 

Last modified object

$lastModified : \Zend\Memory\Container\Movable

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

 

Memory grow limit.

$memoryLimit : integer

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

 

Minimum value size to be swapped.

$minSize : integer

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

 

Id for next Zend_Memory object

$nextId : integer

 

List of object sizes.

$sizes : array

This list is used to calculate modification of object sizes

array( => , ...)

 

List of candidates to unload

$unloadCandidates : array

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

array( => , ... )