Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store


The Zend_Memory component is intended to manage data in an environment with limited memory.

Memory objects (memory containers) are generated by memory manager by request and transparently swapped/loaded when it's necessary.

For example, if creating or loading a managed object would cause the total memory usage to exceed the limit you specify, some managed objects are copied to cache storage outside of memory. In this way, the total memory used by managed objects does not exceed the limit you need to enforce.

The memory manager uses Zend_Cache backends as storage providers.

Example 622. Using Zend_Memory component

Zend_Memory::factory() instantiates the memory manager object with specified backend options.

= array(
'cache_dir' => './tmp/' // Directory where to put the swapped memory blocks

$memoryManager Zend_Memory::factory('File'$backendOptions);

$loadedFiles = array();

for (
$count 0$count 10000$count++) {
$f fopen($fileNames[$count], 'rb');
$data fread($ffilesize($fileNames[$count]));

$loadedFiles[] = $memoryManager->create($data);


$loadedFiles[$index2]->value $newValue;

$loadedFiles[$index3]->value[$charIndex] = '_';

Zend Framework