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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 02:03:23
Script start
Timing: Jan 18 2025 02:03:23
Module start 'layout'
Timing: Jan 18 2025 02:03:23
Module start 'content'
Timing: Jan 18 2025 02:03:24
Module end 'content'
Timing: Jan 18 2025 02:03:24
Script end

Main resources:

Total runtime0.8241 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 588.0469152.6406
Module start 'layout' 0.00760.0166 740.687539.4844
Module start 'content' 0.02420.7982 780.1719619.5391
Module end 'content' 0.82240.0016 1,399.710916.1250
Script end 0.8240  1,415.8359 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4159160.0002
Check MTime0.00140.1694160.0001
Mysql Total
Database connection0.00080.100110.0008
Mysqli_queries0.752691.3256650.0116
Looping result0.00070.0816630.0000
Template Total0.761892.420.3809
Template load0.00230.273720.0011
Template processing0.759592.163820.3797
Template load and register function0.00010.012010.0001
states
state_id_array0.00060.077810.0006
state_identifier_array0.00070.082820.0003
Override
Cache load0.00170.2060330.0001
Sytem overhead
Fetch class attribute can translate value0.00070.086930.0002
Fetch class attribute name0.00140.172380.0002
XML
Image XML parsing0.00150.185330.0005
class_abstraction
Instantiating content class attribute0.00000.0027100.0000
General
dbfile0.00140.1745310.0000
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs