Skip to content

Commit

Permalink
MDL-24751 using new memory constants
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 19, 2010
1 parent c22473a commit 346c588
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 36 deletions.
2 changes: 1 addition & 1 deletion admin/cli/install_database.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
$CFG->early_install_lang = true;
get_string_manager(true);

@raise_memory_limit('128M');
raise_memory_limit(MEMORY_EXTRA);

// now get cli options
list($options, $unrecognized) = cli_get_params(
Expand Down
11 changes: 4 additions & 7 deletions admin/health.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,20 +330,17 @@ function exists() {
global $CFG;

$oldmemlimit = @ini_get('memory_limit');
if(empty($oldmemlimit)) {
if (empty($oldmemlimit)) {
// PHP not compiled with memory limits, this means that it's
// probably limited to 8M or in case of Windows not at all.
// We can ignore it for now - there is not much to test anyway
// TODO: add manual test that fills memory??
return false;
}
$oldmemlimit = get_real_size($oldmemlimit);
//now lets change the memory limit to something unique below 128M==134217728
if (empty($CFG->extramemorylimit)) {
raise_memory_limit('128M');
} else {
raise_memory_limit($CFG->extramemorylimit);
}
//now lets change the memory limit to something higher
$newmemlimit = ($oldmemlimit + 1024*1024*5);
raise_memory_limit($newmemlimit);
$testmemlimit = get_real_size(@ini_get('memory_limit'));
//verify the change had any effect at all
if ($oldmemlimit == $testmemlimit) {
Expand Down
2 changes: 1 addition & 1 deletion admin/report/security/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}

// we may need a bit more memory and this may take a long time to process
@raise_memory_limit('128M');
raise_memory_limit(MEMORY_EXTRA);
@set_time_limit(0);

// Print the header.
Expand Down
2 changes: 1 addition & 1 deletion admin/report/unittest/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Always run the unit tests in developer debug mode.
$CFG->debug = DEBUG_DEVELOPER;
error_reporting($CFG->debug);
raise_memory_limit('256M');
raise_memory_limit(MEMORY_EXTRA);

// page parameters
$path = optional_param('path', null, PARAM_PATH);
Expand Down
6 changes: 1 addition & 5 deletions backup/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,7 @@ function import_backup_file_silently($pathtofile,$destinationcourse,$emptyfirst=
return false;
}
@ini_set("max_execution_time","3000");
if (empty($CFG->extramemorylimit)) {
raise_memory_limit('128M');
} else {
raise_memory_limit($CFG->extramemorylimit);
}
raise_memory_limit(MEMORY_EXTRA);

if (!$backup_unique_code = restore_precheck($destinationcourse,$pathtofile,$errorstr,true)) {
mtrace($debuginfo.'Failed restore_precheck (error was '.$errorstr.')');
Expand Down
4 changes: 2 additions & 2 deletions enrol/database/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function sync_enrolments() {

// we may need a lot of memory here
@set_time_limit(0);
@raise_memory_limit("512M");
raise_memory_limit(MEMORY_HUGE);

$extdb = $this->db_init();

Expand Down Expand Up @@ -477,7 +477,7 @@ public function sync_courses() {

// we may need a lot of memory here
@set_time_limit(0);
@raise_memory_limit("512M");
raise_memory_limit(MEMORY_HUGE);

$extdb = $this->db_init();

Expand Down
4 changes: 2 additions & 2 deletions enrol/ldap/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function sync_user_enrolments($user) {

// We may need a lot of memory here
@set_time_limit(0);
@raise_memory_limit("512M");
raise_memory_limit(MEMORY_HUGE);

// Get enrolments for each type of role.
$roles = get_all_roles();
Expand Down Expand Up @@ -297,7 +297,7 @@ public function sync_enrolments() {

// we may need a lot of memory here
@set_time_limit(0);
@raise_memory_limit("512M");
raise_memory_limit(MEMORY_HUGE);

// Get enrolments for each type of role.
$roles = get_all_roles();
Expand Down
4 changes: 2 additions & 2 deletions grade/import/csv/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
@set_time_limit(0);
@raise_memory_limit("192M");
raise_memory_limit(MEMORY_EXTRA);

// use current (non-conflicting) time stamp
$importcode = get_new_importcode();
Expand Down Expand Up @@ -205,7 +205,7 @@
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
@set_time_limit(0);
@raise_memory_limit("192M");
raise_memory_limit(MEMORY_EXTRA);

// we only operate if file is readable
if ($fp = fopen($filename, "r")) {
Expand Down
2 changes: 1 addition & 1 deletion grade/import/xml/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
@set_time_limit(0);
@raise_memory_limit("256M");
raise_memory_limit(MEMORY_EXTRA);

$text = download_file_content($url);
if ($text === false) {
Expand Down
2 changes: 1 addition & 1 deletion grade/import/xml/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
@set_time_limit(0);
@raise_memory_limit("256M");
raise_memory_limit(MEMORY_EXTRA);

if ($text = $mform->get_file_content('userfile')) {
print_grade_page_head($COURSE->id, 'import', 'xml', get_string('importxml', 'grades'));
Expand Down
4 changes: 2 additions & 2 deletions lib/cronlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function cron_run() {
$starttime = microtime();

/// increase memory limit (PHP 5.2 does different calculation, we need more memory now)
@raise_memory_limit('128M');
raise_memory_limit(MEMORY_EXTRA);

/// emulate normal session
cron_setup_user();
Expand Down Expand Up @@ -333,7 +333,7 @@ function cron_run() {
//Execute backup's cron
//Perhaps a long time and memory could help in large sites
@set_time_limit(0);
@raise_memory_limit("192M");
raise_memory_limit(MEMORY_EXTRA);
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
file_exists("$CFG->dirroot/backup/backuplib.php") and
file_exists("$CFG->dirroot/backup/lib.php") and
Expand Down
4 changes: 2 additions & 2 deletions mod/assignment/type/online/assignment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public function send_file($filearea, $args) {
public function download_submissions() {
global $CFG, $DB;

@raise_memory_limit('256M');
raise_memory_limit(MEMORY_EXTRA);

$submissions = $this->get_submissions('','');
if (empty($submissions)) {
Expand All @@ -403,7 +403,7 @@ public function download_submissions() {
} else {
$groupmode = $this->course->groupmode;
}

$groupid = 0; // All users
$groupname = '';
if ($groupmode) {
Expand Down
2 changes: 1 addition & 1 deletion mod/data/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
// that we'll take longer, and that the process should be recycled soon
// to free up memory.
@set_time_limit(0);
@raise_memory_limit("96M");
raise_memory_limit(MEMORY_EXTRA);

$iid = csv_import_reader::get_new_iid('moddata');
$cir = new csv_import_reader($iid, 'moddata');
Expand Down
8 changes: 2 additions & 6 deletions search/cron_php5.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Moodle global search engine
* This is a special externalized code for cron handling in PHP5.
* Should never be called by a php 4.3.0 implementation.
* Should never be called by a php 4.3.0 implementation.
* @package search
* @category core
* @subpackage search_engine
Expand All @@ -14,11 +14,7 @@

try{
ini_set('max_execution_time', 300);
if (empty($CFG->extramemorylimit)) {
raise_memory_limit('128M');
} else {
raise_memory_limit($CFG->extramemorylimit);
}
raise_memory_limit(MEMORY_EXTRA);

mtrace("\n--DELETE----");
require_once($CFG->dirroot.'/search/delete.php');
Expand Down
4 changes: 2 additions & 2 deletions webservice/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ public function __construct($authmethod, $zend_class) {
*/
public function run() {
// we will probably need a lot of memory in some functions
@raise_memory_limit('128M');
raise_memory_limit(MEMORY_EXTRA);

// set some longer timeout, this script is not sending any output,
// this means we need to manually extend the timeout operations
Expand Down Expand Up @@ -1141,7 +1141,7 @@ abstract protected function send_error($ex=null);
*/
public function run() {
// we will probably need a lot of memory in some functions
@raise_memory_limit('128M');
raise_memory_limit(MEMORY_EXTRA);

// set some longer timeout, this script is not sending any output,
// this means we need to manually extend the timeout operations
Expand Down

0 comments on commit 346c588

Please sign in to comment.