Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Static Publishing - memory issue - FileSystemPublisher/Director

Go to End



Community Member, 3 Posts

5 January 2010 at 2:38am

I've got some serious performance problems with Silverstripe so I hoped to find a solution in static publishing my site. When performing .../dev/buildcache?flush=1 I get an 'out of memory' error.

Because I don't understand why such a simple action should take lots of memory I tried to analyse the code. It seems that the following line in cms/code/statispublisher/FileSystemPublisher.php is responsible for the increase in memory:
$response = Director::test($url);
This lines eventualy calls Director::handleRequest(...) so the real issue goes deeper.

You can see what's happening if you just call this method multiple times for the same url. Then you see the memory usage grow:
for($i=0;$i<100;$i++) {
echo "--- iteration $i with memory usage: " , memory_get_usage() , "\n";
$response = Director::test($url);

The outpout shows:
--- iteration 0 with memory usage: 17106200
--- iteration 1 with memory usage: 20147872
--- iteration 2 with memory usage: 20350432
--- iteration 98 with memory usage: 39963656
--- iteration 99 with memory usage: 40166176

Is it possible this is a memory leak in a static function? Is there a simple workaround available?

php 5.2.11
Sivlerstripe 2.3.3