Forums / Developer / resetDataMap and eZContentObject::clearCache
Marko Žmak
Wednesday 02 February 2011 9:21:19 am
While debugging some memory leakage in my script I ran into this forum post:
http://share.ez.no/forums/developer/memory-problem-will-running-cronjob
Using:
$object->resetDataMap(); eZContentObject::clearCache( array( $object->attribute('id') ) );
helped solving my leakage problem, but the interesting part is that using only eZContentObject::clearCache() without resetDataMap() also solved my problem.
So, is resetDataMap() really needed when you use eZContentObject::clearCache(), ok can we go without it?
-- Nothing is impossible. Not if you can imagine it! Hubert Farnsworth
Damien Pobel
Thursday 03 February 2011 1:06:44 pm
Hi Marko,
AFAIK, eZContentObject::clearCache() is usually enough to circumvent memory issues in CLI scripts because it clears a cache that stores all content objects in memory while eZContentObject::resetData() only clears the data map of the object that can be quite small and should be cleared by clearCache() anyway.
Cheers
Damien Planet eZ Publish.fr : http://www.planet-ezpublish.fr Certification : http://auth.ez.no/certification/verify/372448 Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish
Jérôme Vieilledent
Friday 04 February 2011 12:43:59 am
Hello Marko and Damien
I already had memory issues using only eZContentObject::clearCache(). Normally it would indeed clear all the circular references to the object, it actually doesn't. I don't know why, maybe a PHP issue but anyway, the best way to avoid memory leaks is to use both eZContentObject::clearCache() and eZContentObject::resetDataMap().
Here you can find an example in SQLIImport content framework (loot at the flush() method, call by the destructor) :
Friday 04 February 2011 1:27:22 am
Hi,
I guess you encountered those problems with PHP 5.2 ? PHP 5.3 solves a lot of problem in memory management.
Anyway,there's no problem in calling both resetDataMap() and clearCache() methods in a CLI scripts.
Friday 04 February 2011 2:22:35 am
Yes, it was with PHP 5.2.x