Virtual Memory Size

2 posts by 2 authors in: Forums > CMS Builder
Last Post: April 25, 2017   (RSS)

By Toledoh - April 23, 2017

There’s been some changes on my server which means I am now getting server alert emails that didn’t used to get through to me.  Over the weekend, I got about 200 similar to the one below for a bunch of sites.

Time:         Mon Apr 24 13:55:22 2017 +1000
Account:      saintpatricksqld
Resource:     Virtual Memory Size
Exceeded:     212 > 200 (MB)
Executable:   /usr/bin/php
Command Line: /usr/bin/php /home/saintpatricksqld/public_html/index.php
PID:          1433 (Parent PID:900)
Killed:       No

I’ve added memory_limit = 128M ; to php.ini, which I think has made a difference, however I was wondering if I should be doing something different in the construction of my websites to reduce the amount of memory used?

i.e.. http://www.interactivetools.com/forum/forum-posts.php?postNum=2233586#post2233586 says to include 

  'loadCreatedBy' => false, // optional, defaults to yes, adds createdBy. fields for created user


Should I include that kind of thing by default?

Cheers,

Tim (toledoh.com.au)

By Dave - April 25, 2017

Hi Tim, 

Generally, because servers are much cheaper than programming time we recommend optimizing last.  With most general sites you'll never have to.  And then when it becomes a problem you can "spot optimize" as needed.

My first guess is you're loading a table with 100 or 1000+ records completely into memory.  loadCreatedBy will save a bit of memory but not much.  If you're using over 200 megs then a LOT of data is being loaded into memory.

You could try this plugin I wrote a while back to alert you to any memory heavy or slow loading pages.  Anytime it detects a page that takes over 2 seconds to load or 10 megs of memory (those limits are configurable) it logs an entry in the error log.  It's great for finding problem pages:
https://www.interactivetools.com/forum/forum-posts.php?postNum=2237150#post2237150

Also, setting the PHP memory_limit will just have the script die with an error (eg: HTTP 500 Script Error) or stop half way through loading when the memory limit is reached.  You really want to get to the root cause.  It's almost always loading lots and lots of records when it's not needed.

Hope that helps, let me know any questions!

Dave Edis - Senior Developer
interactivetools.com