5

I'm having an issue with, what I consider high memory usage, on a ExpressionEngine v2.5.3 install. This is a recent EE1 - EE2 upgrade if that makes a difference.

An empty template on this project uses 10MB of memory. I tested on another v2.5.3 project and an empty page there is using 2MB of memory. I'm seeing 30+MB usage on normal templates and frequently the browser loses its connection to the server.

Is an addon causing this increased memory usage? What's the best way to track this backwards?

The install is definitely acting up after this upgrade.


TEMPLATE DEBUGGING

(0.000011 / 9.01MB) - Begin Template Processing -
(0.000172 / 9.01MB) URI: test
(0.000185 / 9.01MB) Path.php Template: /
(0.000199 / 9.01MB) Retrieving Template
(0.000210 / 9.01MB) Parsing Template URI
(0.002112 / 9.02MB) Template Group Found: test
(0.002166 / 9.02MB) Retrieving Template from Database: test/index
(0.003599 / 9.02MB) Template Found
(0.003690 / 9.02MB) Template Type: webpage
(0.003711 / 9.02MB) Parsing Site Variables
(0.003767 / 9.02MB) Snippets (Keys): structure:is:page|structure:is:listing|structure:is:listing:parent|structure:page:entry_id|structure:page:template_id|structure:page:title|structure:page:slug|structure:page:uri|structure:page:url|structure:page:channel|structure:page:channel_short_name|structure:parent:entry_id|structure:parent:title|structure:parent:slug|structure:parent:uri|structure:parent:url|structure:parent:child_ids|structure:parent:channel|structure:parent:channel_short_name|structure:top:entry_id|structure:top:title|structure:top:slug|structure:top:uri|structure:top:url|structure:child_listing:channel_id|structure:child_listing:short_name|structure:freebie:entry_id|structure:child_ids|structure:sibling_ids|structure_1|structure_2|structure_3|structure_4|structure_5|structure_6|structure_7|structure_8|structure_9|structure_10|structure_last_segment|site_id|site_label|site_short_name|last_segment
(0.003784 / 9.02MB) Snippets (Values): FALSE||||||||||||||||||||||test|/test/|/test/||||||test||||||||||test|1|Ranch|default_site|test
(0.003926 / 9.02MB) Parse Date Format String Constants
(0.003943 / 9.02MB) Parse Current Time Variables
(0.003968 / 9.02MB) Parsing Segment, Embed, and Global Vars Conditionals
(0.007698 / 9.11MB) - Beginning Tag Processing -
(0.007719 / 9.11MB) - End Tag Processing -
(0.008645 / 9.12MB) Calling Extension Class/Method: Structure_ext/template_post_parse
(0.008789 / 9.11MB) - End Template Processing -
(0.008803 / 9.11MB) Parse Global Variables
(0.009574 / 9.11MB) Template Parsing Finished
Memory Usage: 10,163,144 bytes
Anna_MediaGirl
  • 1,120
  • 13
  • 31

4 Answers4

9

Different versions of php, and different ways of implementing php ie: mod_php vs. fastcgi for instance, along with different functions enabled in php itself can lead to different levels of memory usage.

To test memory usage for just php being executed rather than in EE's template engine try the code below.

<?php
    function echo_memory_usage() {
        $mem_usage = memory_get_usage(true);

        if ($mem_usage < 1024)
            echo $mem_usage." bytes";
        elseif ($mem_usage < 1048576)
            echo round($mem_usage/1024,2)." kilobytes";
        else
            echo round($mem_usage/1048576,2)." megabytes";

        echo "<br/>";
    }
?>
Nevin Lyne
  • 349
  • 1
  • 4
  • 256 kilobytes prints out when in just a regular PHP file. – Anna_MediaGirl Oct 28 '12 at 19:30
  • 9.25 megabytes is what prints out when in an EE template – Anna_MediaGirl Oct 28 '12 at 19:37
  • For what it's worth, I've just run a couple of tests on a local MAMP server with a more or less vanilla EE install and an empty template. With APC (opcode caching) disabled the template debugger output is almost exactly the same as yours, about 9MB. With APC enabled it drops to 2MB after the initial request. Do you have other sites running on this server? Is their performance markedly better? If not, I think you want to look at the server rather than EE. – Dom Stubbs Oct 28 '12 at 20:05
  • No other sites on this host unfortunately. Very odd that you are seeing 9MB while I'm seeing 2MB on another install with same version. – Anna_MediaGirl Oct 28 '12 at 20:12
  • MediaGirl, Do you have APC bytecode caching on the the other server that sees 2MB usage instead of 9MB? – Nevin Lyne Oct 28 '12 at 20:15
  • That template is on a site with CE Cache installed but I'm not calling it in the template. It's an account on your servers. Tested on another on your servers too and got the 9mb. – Anna_MediaGirl Oct 28 '12 at 23:53
  • Ok so initial site in this question is not hosted on EH, the one you see the 2MB usage is on EH, but if you test on another account at EH you still see 9MB. Sounding more and more like 9MB is without APC caching, 2MB is with APC caching. I can confirm with you in email in reference to the EH tests. Keep in mind EE 2 has a larger memory footprint than EE 1. APC does what is called bytecode caching, which along a few things lowers memory usage after its cached. – Nevin Lyne Oct 29 '12 at 00:30
  • "seeing 30+MB usage on normal templates" - Will of course vary based on add-ons and other factors in those templates... and "frequently the browser loses its connection to the server" Sounds less like its related to this memory usage and more towards the web host you are using for this site overall. – Nevin Lyne Oct 29 '12 at 00:33
3

you can pinpoint bottlenecks quite quickly with the Graphite add-on:

https://github.com/joelbradbury/Graphite.ee_addon

I find Graphite itself can really slow down your pages, but if you can get it to load ok it's awesome.

James Smith
  • 528
  • 3
  • 9
3

Starting with an empty template, with Template Debugging turned on, is a good start and eliminates any chance of tags causing the high memory use.

Is there anything different setting or add-on-wise between your 2Mb-usage installs and your current 10Mb-usage install? With template tags eliminated as a cause, you might want to look into add-ons that might be adding overhead, in particular extensions. Feel free to post the add-ons you have installed here.

Also disabling tracking and saving templates as files might save you some memory.

Zenbuman
  • 106
  • 2
  • The 10MB memory usage is from an empty template. Yes, this install is different from the 2MB one... different sites all together but same EE version. Tracking is off. Not saving as templates. Only addon being called in the blank template is Structure. I can see this in the queries. – Anna_MediaGirl Oct 28 '12 at 19:24
  • Could you, just as a test, dupe the db, delete structure, then try to load a blank template and see what the difference is? – Tyssen Oct 29 '12 at 00:12
2

It seems the answer to my question is ~9MB is a normal starting level for a blank template on an EE install.

The template which starts at 2MB is on an EngineHosting VPS/VSC account with APC bytecode caching enabled, hence the difference in numbers.

Anna_MediaGirl
  • 1,120
  • 13
  • 31