Forums / Developer / How to build an update CLI script without memory problem ? / Comment51113
Stéphane Couzinier
Wednesday 03 June 2009 3:12:56 am
If you need to extract a lot of data this will work
<?php $userId = eZUser::currentUser()->id(); $limit=1000; $offset=0; do{ $nodes = &eZContentObjectTreeNode::subTreeByNodeId( array("Limit" => $limit,'Offset',$offset) , 2 ); foreach($nodes as $node){ $data = &$node->dataMap(); eZContentObject::clearCache(); unset( $GLOBALS['eZContentObjectContentObjectCache'] ); unset( $GLOBALS['eZContentObjectDataMapCache'] ); unset( $GLOBALS['eZContentObjectVersionCache'] ); unset( $GLOBALS['eZContentClassAttributeCache'] ); unset( $GLOBALS["eZUserObject_".$node->ContentObjectID] ); unset( $data ); } $offset+=$limit; echo memory_get_usage() . "\n"; }while( !empty( $nodes) ); ?>
mem usage 59751392 59814408 59946280 59950608 59946168 59952120 5995776859936880
http://www.kouz-cooking.fr