- Function for raising the memory limit to prevent exhausted memory error messages
Memory limit
1 /** begin :: checking and raising memory limit **/
2 function check_memory_consumption() {
3 $current_use = ceil( memory_get_usage() / (1000*1000) );
4 $limit = ((int)ini_get('memory_limit') - 10);
5
6 if ( $current_use >= $limit ){
7 ini_set('memory_limit', sprintf('%dM', ($current_use+10+100) ));
8 echo 'Memory limit was raised to: '.ini_get('memory_limit').'<br />';
9 flush();
10 }
11 }
12 /** end :: checking and raising memory limit **/
Comments
Sign in to leave a comment.

