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

Returns

int

Get minimum size of values, which may be swapped

getMinSize() : int

Returns

int

Set memory grow limit

setMemoryLimit(int $newLimit) 

Parameters

$newLimit

int

Set minimum size of values, which may be swapped

setMinSize(int $newSize) 

Parameters

$newSize

int

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

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, int $id) 

Parameters

$id

int

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

 

Memory grow limit.

$memoryLimit : int

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

 

Overall size of memory, used by values

$memorySize : int

 

Minimum value size to be swapped.

$minSize : int

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

 

Id for next Zend\Memory object

$nextId : int

 

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( => , ... )