Forums / Developer / resetDataMap and eZContentObject::clearCache

resetDataMap and eZContentObject::clearCache

Author Message

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

Damien Pobel

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.

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 2:22:35 am

Yes, it was with PHP 5.2.x

eZ debug

Timing: Jan 29 2025 13:42:59
Script start
Timing: Jan 29 2025 13:42:59
Module start 'content'
Timing: Jan 29 2025 13:42:59
Module end 'content'
Timing: Jan 29 2025 13:42:59
Script end

Main resources:

Total runtime0.0168 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 588.0625180.8203
Module start 'content' 0.00880.0045 768.882898.0703
Module end 'content' 0.01330.0035 866.953174.6875
Script end 0.0167  941.6406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002313.5309120.0002
Check MTime0.00116.8166120.0001
Mysql Total
Database connection0.00074.212910.0007
Mysqli_queries0.005633.536040.0014
Looping result0.00000.160520.0000
Template Total0.003218.910.0032
Template load0.00084.545310.0008
Template processing0.002414.329110.0024
Override
Cache load0.00052.926110.0005
General
dbfile0.00042.3068100.0000
String conversion0.00000.029830.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs