This section describes creating and destroying objects in the managed memory, and settings to control memory manager behavior.
Create movable objects (objects, which may be swapped) using
the Zend_Memory_Manager::create([$data]) method:
<?php
$memObject = $memoryManager->create($data);
The $data argument is optional and used to
initialize the object value. If the $data
argument is omitted, the value is an empty string.
Create locked objects (objects, which are not swapped) using
the Zend_Memory_Manager::createLocked([$data]) method:
<?php
$memObject = $memoryManager->createLocked($data);
The $data argument is optional and used to
initialize the object value. If the $data
argument is omitted, the value is an empty string.
Memory objects are automatically destroyed and removed from memory when they go out of scope:
<?php
function foo()
{
global $memoryManager, $memList;
...
$memObject1 = $memoryManager->create($data1);
$memObject2 = $memoryManager->create($data2);
$memObject3 = $memoryManager->create($data3);
...
$memList[] = $memObject3;
...
unset($memObject2); // $memObject2 is destroyed here
...
// $memObject1 is destroyed here
// but $memObject3 object is still referenced by $memList
// and is not destroyed
}
This applies to both movable and locked objects.




