Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know that it is possible to restrict (or extend) the memory usage of the entire WP site using:

define('WP_MEMORY_LIMIT', '64M')

Is it possible to do the same for only one plugin that the website uses ?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

No and even if you could, if the plugin ran out of available memory then the entire page generation would stop due to the fatal error.

You're better off fixing the plugin itself to not use as much memory or to just further increase the total memory allocated to WordPress/PHP.

share|improve this answer
    
Thank you for the answer. –  Tal Galili Sep 8 '10 at 4:25

Generally spoken, no, it is not possible for a particular plugin only. The plugin runs in the whole wordpress PHP process (normally) and therefore it shares the memory limit setting with the rest.

You can however try to limit the memory before each time the plugin is called. That would be prior any hook of it (that's possible) and then in the beginning prior the inclusion (that's much harder to achieve).

The define of WP_MEMORY_LIMIT gets overwritten by the way, so setting that constant to something is not useful if you actually want to limit memory.

If you do not fear to deal with system internals, you can however limit the memory for the whole process properly as well as if you like it experimental, you can give runkit a try and execute the plugins code therein - somehow.

share|improve this answer
    
What do you mean when you say that WP_MEMORY_LIMIT gets overwritten? Since it's a constant, its value can't change once it's been set. wp_initial_constants() only sets the value if it hasn't already been set in wp-config.php. –  Ian Dunn Oct 26 '11 at 17:40
    
@Ian Dunn: Sure, the constant does not get overwritten, but the value it carries will get before it's being applied to the memory limit call. At least it was, this has been improved some time ago in trunk, I think WP 3.2 benefits from these changes. –  hakre Oct 26 '11 at 22:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.