Question

Some pages on Drupal use more memory than other pages. I think it's a waste of server resources to reserve 64M or more to all pages in Drupal only because the modules' page (or a section with graphics) reaches this peak and I want to avoid white pages when doing changes.

So, my question is: Is it a good practice to manage different memory limits programmatically, depending of the section or page? Some pages use 32M or less, so I think it's better to optimize specific sections of a web app with specific limits.

I've read a lot about optimization practices but I haven't found handling memory limits dynamically or a Drupal module dealing this kind of matter or applying this approach.

Was it helpful?

Solution

The memory limit is really just telling Drupal how much memory it's allowed to use. Drupal isn't going to "reserve" memory. It doesn't really "manage" memory at all the way you think. It'll use whatever it needs (of the allowed) when it needs it, and if it needed more, you'll get an error. If it needs less than the memory limit, it'll use less.

The minimum required available memory for Drupal 7 to run is 32MB, but a recommended number would be closer to 128MB.

http://drupal.org/requirements#php

PHP memory requirements can vary significantly depending on the modules in use on your site. Drupal 6 core requires PHP's memory_limit to be at least 16MB. Drupal 7 core requires 32MB. Warning messages will be shown if the PHP configuration does not meet these requirements. However, while these values may be sufficient for a default Drupal installation, a production site with a number of commonly used modules enabled (CCK, Views etc.) could require 64 MB or more. Some installations may require much more, especially with media-rich implementations. If you are using a hosting service it is important to verify that your host can provide sufficient memory for the set of modules you are deploying or may deploy in the future. (See the Increase PHP memory limit page in the Troubleshooting FAQ for additional information on modifying the PHP memory limit.)

OTHER TIPS

Drupal is very memory heavy. When warming up an instance of drupal for the very first time, it tries to allocate memory to the views, cache etc..

Be sure to place this inside sites/default/settings.php

ini_set('memory_limit','128M');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top