Revision fc62ac50
Added by Christopher Cope almost 2 years ago
src/etc/inc/config.inc | ||
---|---|---|
33 | 33 |
//if (in_array("/etc/inc/config.inc", get_included_files())) |
34 | 34 |
// return; |
35 | 35 |
|
36 |
// Set the memory limit to 128M on i386. When someone has something like 500+ tunnels |
|
37 |
// the parser needs quite a bit of ram. Do not remove this line unless you |
|
38 |
// know what you are doing. If in doubt, check with dev@ _/FIRST/_! |
|
39 |
if (!isset($ARCH)) { |
|
40 |
$ARCH = php_uname("m"); |
|
41 |
} |
|
42 |
|
|
43 |
// Set memory limit to 512M on amd64. |
|
44 |
if ($ARCH == "amd64") { |
|
45 |
ini_set("memory_limit", "512M"); |
|
46 |
} else { |
|
47 |
ini_set("memory_limit", "128M"); |
|
48 |
} |
|
49 |
|
|
50 | 36 |
/* include globals from notices.inc /utility/XML parser files */ |
51 | 37 |
require_once("notices.inc"); |
52 | 38 |
require_once("util.inc"); |
... | ... | |
55 | 41 |
require_once("xmlparse.inc"); |
56 | 42 |
require_once("crypt.inc"); |
57 | 43 |
|
44 |
// Set the memory limit to 128M on i386. When someone has something like 500+ tunnels |
|
45 |
// the parser needs quite a bit of ram. Do not remove this line unless you |
|
46 |
// know what you are doing. If in doubt, check with dev@ _/FIRST/_! |
|
47 |
if (!$ARCH) { |
|
48 |
$ARCH = php_uname("m"); |
|
49 |
} |
|
50 |
|
|
51 |
// Set memory limit to 512M on amd64. |
|
52 |
ini_set("memory_limit", get_php_default_memory($ARCH) . 'M'); |
|
53 |
|
|
58 | 54 |
/* if /debugging exists, lets set $debugging |
59 | 55 |
so we can output more information */ |
60 | 56 |
if (file_exists("/debugging")) { |
... | ... | |
151 | 147 |
} |
152 | 148 |
date_default_timezone_set("$timezone"); |
153 | 149 |
|
150 |
/* override php memory limit */ |
|
151 |
$php_memory_limit = config_get_path('system/php_memory_limit', 0); |
|
152 |
if (($php_memory_limit >= 128) && ($php_memory_limit <= get_php_max_memory())) { |
|
153 |
ini_set("memory_limit", config_get_path('system/php_memory_limit') . "M"); |
|
154 |
} |
|
155 |
|
|
154 | 156 |
if ($config_parsed == true) { |
155 | 157 |
/* process packager manager custom rules */ |
156 | 158 |
if (is_dir("/usr/local/pkg/parse_config")) { |
src/etc/inc/util.inc | ||
---|---|---|
2467 | 2467 |
return array(((int) $physmem/1048576), ((int) $realmem/1048576)); |
2468 | 2468 |
} |
2469 | 2469 |
|
2470 |
function get_php_default_memory($ARCH) { |
|
2471 |
if ($ARCH == "amd64") { |
|
2472 |
return 512; |
|
2473 |
} else { |
|
2474 |
return 128; |
|
2475 |
} |
|
2476 |
} |
|
2477 |
|
|
2478 |
function get_php_max_memory() { |
|
2479 |
return intval(get_memory()[0] - 1024); |
|
2480 |
} |
|
2481 |
|
|
2470 | 2482 |
function mute_kernel_msgs() { |
2471 | 2483 |
if (config_path_enabled('system','enableserial')) { |
2472 | 2484 |
return; |
src/etc/rc.php_ini_setup | ||
---|---|---|
251 | 251 |
EOF |
252 | 252 |
fi |
253 | 253 |
|
254 |
# Memory limits 128M to AVAILABLE MEMORY - 1024M |
|
255 |
PHP_MEMORY_LIMIT="$(read_xml_tag.sh number system/php_memory_limit)" |
|
256 |
let PHP_MAX_LIMIT=${AVAILMEM}-1024 # Reserve 1GiB |
|
257 |
|
|
258 |
if [ -n "${PHP_MEMORY_LIMIT}" ] && [ "${PHP_MEMORY_LIMIT}" -ge "128" ] && [ "${PHP_MEMORY_LIMIT}" -le "${PHP_MAX_LIMIT"}" ]; then |
|
259 |
/bin/cat >>/usr/local/etc/php.ini <<EOF |
|
260 |
memory_limit="${PHP_MEMORY_LIMIT}"M |
|
261 |
EOF |
|
262 |
fi |
|
263 |
|
|
254 | 264 |
PHPFPMMAX=3 |
255 | 265 |
PHPFPMIDLE=30 |
256 | 266 |
PHPFPMSTART=1 |
src/usr/local/pfSense/include/www/system_advanced_misc.inc | ||
---|---|---|
89 | 89 |
$pconfig['do_not_send_uniqueid'] = isset($config['system']['do_not_send_uniqueid']); |
90 | 90 |
$pconfig['pti'] = get_single_sysctl('vm.pmap.pti'); |
91 | 91 |
$pconfig['mds']= get_single_sysctl('hw.mds_disable_state'); |
92 |
$pconfig['php_memory_limit'] = config_get_path('system/php_memory_limit'); |
|
92 | 93 |
|
93 | 94 |
$pconfig['powerd_ac_mode'] = "hadp"; |
94 | 95 |
if (!empty($config['system']['powerd_ac_mode'])) { |
... | ... | |
200 | 201 |
$input_errors[] = gettext("Invalid MDS Mode."); |
201 | 202 |
} |
202 | 203 |
|
204 |
// Retrieve limit |
|
205 |
$php_max_ram = get_php_max_memory(); |
|
206 |
|
|
207 |
if (!empty($post['php_memory_limit']) && ((!is_numeric($post['php_memory_limit'])) || ($post['php_memory_limit'] > $php_max_ram) |
|
208 |
|| ($post['php_memory_limit'] < 128))) { |
|
209 |
$input_errors[] = gettext("PHP Memory Limit must be numeric and should be between 128 to " . $php_max_ram); |
|
210 |
} |
|
211 |
|
|
203 | 212 |
if (!$input_errors) { |
204 | 213 |
|
205 | 214 |
if ($post['harddiskstandby'] <> "") { |
... | ... | |
374 | 383 |
} |
375 | 384 |
} |
376 | 385 |
|
386 |
// PHP Memory Limit |
|
387 |
if (!empty($post['php_memory_limit'])) { |
|
388 |
config_set_path('system/php_memory_limit', $post['php_memory_limit']); |
|
389 |
} else { |
|
390 |
config_del_path('system/php_memory_limit'); |
|
391 |
} |
|
392 |
|
|
377 | 393 |
// Add/Remove RAM disk periodic backup cron jobs according to settings and installation type. |
378 | 394 |
// Remove the cron jobs on full install if not using RAM disk. |
379 | 395 |
// Add the cron jobs on all others if the periodic backup option is set. Otherwise the cron job is removed. |
src/usr/local/www/system_advanced_misc.php | ||
---|---|---|
36 | 36 |
require_once("guiconfig.inc"); |
37 | 37 |
require_once("functions.inc"); |
38 | 38 |
require_once("filter.inc"); |
39 |
require_once("system.inc"); |
|
39 | 40 |
require_once("shaper.inc"); |
40 | 41 |
require_once("vpn.inc"); |
41 | 42 |
require_once("system_advanced_misc.inc"); |
... | ... | |
319 | 320 |
'Enabling this checkbox overrides that behavior.'); |
320 | 321 |
|
321 | 322 |
$form->add($section); |
323 |
|
|
324 |
// Retrieve limits |
|
325 |
$php_default = get_php_default_memory($ARCH); |
|
326 |
$php_max_ram = get_php_max_memory(); |
|
327 |
|
|
328 |
$section = new Form_Section('PHP Settings'); |
|
329 |
|
|
330 |
$group = new Form_Group('Memory Limit'); |
|
331 |
|
|
332 |
$group->add(new Form_Input( |
|
333 |
'php_memory_limit', |
|
334 |
'Memory Limit', |
|
335 |
'number', |
|
336 |
str_replace("M", "", $pconfig['php_memory_limit']), |
|
337 |
['min' => 128, 'max' => $php_max_ram, 'placeholder' => '128 to ' . $php_max_ram] |
|
338 |
))->setHelp('PHP memory limit in MiB.%1$sNote: Leave this blank for the default. On this system the default size is: %2$d ' |
|
339 |
, '<br/>', $php_default); |
|
340 |
|
|
341 |
$section->add($group); |
|
342 |
|
|
343 |
$form->add($section); |
|
344 |
|
|
322 | 345 |
$section = new Form_Section('RAM Disk Settings (Reboot to Apply Changes)'); |
323 | 346 |
|
324 | 347 |
$section->addInput(new Form_Checkbox( |
Also available in: Unified diff
Add a setting for PHP memory limit in System -> Advanced. Feature #13377