Project

General

Profile

Actions

Feature #13377

closed

Option to configure a custom value for the PHP memory limit

Added by Christopher Cope over 2 years ago. Updated 12 months ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
PHP Interpreter
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
(Total: 0.00 h)
Plus Target Version:
23.09
Release Notes:
Default

Description

There are several cases where the default memory limit used for PHP is being hit and where the system has plenty of extra RAM. In these cases, it would make sense to be able to adjust the limit as needed.

For instance, with an extremely large status_output, a large number of nested aliases, etc.


Files


Subtasks 1 (0 open1 closed)

pfSense Packages - Bug #14683: PHP error on ``status_frr.php`` from using too much memoryDuplicate

Actions
Actions #3

Updated by Christopher Cope over 2 years ago

The change only applies to the PHP used directly by pfSense, as they are set with config.inc.

For testing you can use

<?php
require_once("/etc/inc/config.inc");

echo ini_get("memory_limit");

?>

That inc will be loaded automatically inside pfSense. Also there is no need for a reboot for it to take effect.

Actions #4

Updated by Lev Prokofev over 2 years ago

Got it and checked, working as expected.

Actions #5

Updated by Jim Pingle over 2 years ago

  • Subject changed from Allow adjusting the PHP memory_limit in System -> Advanced to Option to configure a custom value for the PHP memory limit
  • Target version set to 2.7.0
  • Plus Target Version set to 22.11
Actions #6

Updated by Jim Pingle about 2 years ago

  • Plus Target Version changed from 22.11 to 23.01
Actions #7

Updated by Jim Pingle about 2 years ago

  • Plus Target Version changed from 23.01 to 23.05
Actions #8

Updated by Jim Pingle over 1 year ago

  • Plus Target Version changed from 23.05 to 23.09
Actions #9

Updated by Jim Pingle over 1 year ago

  • Target version changed from 2.7.0 to CE-Next
Actions #10

Updated by Jonathan Lee over 1 year ago

Could this also be adapted to use a disk swap? That way it could have an option to use and allocate fixed disk storage if needed or required. Kind of Like a reverse MS-DOS ramdisk if you are old enough to remember using this within MS-DOS 5 I think it was.

Actions #11

Updated by Jonathan Lee over 1 year ago

is the Path Strip Count 2 for the patch?

Actions #12

Updated by Jonathan Lee over 1 year ago

I added your patch set this to 512mb and I am still getting that snort error for active rules

Crash report begins. Anonymous machine information:

arm64
14.0-CURRENT
FreeBSD 14.0-CURRENT #1 plus-RELENG_23_05_1-n256108-459fc493a87: Wed Jun 28 04:25:15 UTC 2023 root@freebsd:/var/jenkins/workspace/pfSense-Plus-snapshots-23_05_1-main/obj/aarch64/0P4W6joa/var/jenkins/workspace/pfSense-Plus-snapshots-23_05_1-main/source

Crash report details:

PHP Errors:
[04-Aug-2023 09:30:42 US/Pacific] PHP Fatal error: str_ireplace(): Cannot use output buffering in output buffering display handlers in /usr/local/www/csrf/csrf-magic.php on line 161

No FreeBSD crash data found.

Actions #13

Updated by Christopher Cope over 1 year ago

Jonathan Lee wrote in #note-12:

I added your patch set this to 512mb and I am still getting that snort error for active rules

Crash report begins. Anonymous machine information:

arm64
14.0-CURRENT
FreeBSD 14.0-CURRENT #1 plus-RELENG_23_05_1-n256108-459fc493a87: Wed Jun 28 04:25:15 UTC 2023 root@freebsd:/var/jenkins/workspace/pfSense-Plus-snapshots-23_05_1-main/obj/aarch64/0P4W6joa/var/jenkins/workspace/pfSense-Plus-snapshots-23_05_1-main/source

Crash report details:

PHP Errors:
[04-Aug-2023 09:30:42 US/Pacific] PHP Fatal error: str_ireplace(): Cannot use output buffering in output buffering display handlers in /usr/local/www/csrf/csrf-magic.php on line 161

No FreeBSD crash data found.

That error doesn't seem to be related to memory issues, so this patch wouldn't affect it.

Actions #14

Updated by Christopher Cope over 1 year ago

Jonathan Lee wrote in #note-10:

Could this also be adapted to use a disk swap? That way it could have an option to use and allocate fixed disk storage if needed or required. Kind of Like a reverse MS-DOS ramdisk if you are old enough to remember using this within MS-DOS 5 I think it was.

Right now, this just adds a GUI interface for the existing PHP memory limit settings. In almost all cases, the default values are sufficient.

I don't see there being much of a need to allocate disk space as well, but you could theoretically create a swap partition and increase this value to the point that it would start using that. That's definitely not tested nor recommended, though.

Actions #15

Updated by Jonathan Lee over 1 year ago

Thanks for the reply,

just to confirm the is the Path Strip Count 2 for your patch?

Actions #16

Updated by Christopher Cope over 1 year ago

Jonathan Lee wrote in #note-15:

Thanks for the reply,

just to confirm the is the Path Strip Count 2 for your patch?

That should be correct. Some updates are being made to the code still, so that's delaying the merge. That original patch is still functional, though.

Actions #17

Updated by Jim Pingle over 1 year ago

  • Status changed from Pull Request Review to Feedback
  • Target version changed from CE-Next to 2.8.0

MR Merged

Actions #18

Updated by Christopher Cope about 1 year ago

Tested on

23.09-DEVELOPMENT (amd64)
built on Sat Aug 26 17:37:15 UTC 2023
FreeBSD 14.0-ALPHA2

It's merged in and functioning as expected. I'll wait for others to test as well, since I made the changes.

Actions #19

Updated by Chris W about 1 year ago

Systems with 1GB or less of RAM show a negative number as the hinted maximum adjusted value. The screenshot is taken from a virtual machine with 512 MB RAM (and with 1GB, the value becomes 128 to -62).

Actions #20

Updated by Christopher Cope about 1 year ago

Chris W wrote in #note-19:

Systems with 1GB or less of RAM show a negative number as the hinted maximum adjusted value. The screenshot is taken from a virtual machine with 512 MB RAM (and with 1GB, the value becomes 128 to -62).

Thanks for catching that. I have submitted a merge request to handle those cases more elegantly.
https://gitlab.netgate.com/pfSense/pfSense/-/merge_requests/1065

Actions #21

Updated by yon Liu about 1 year ago

Should allow the user to fill in the PHP memory according to the total memory capacity of the server

Actions #22

Updated by Jordan G about 1 year ago

still seeing a negative number suggested for the higher limit on system with <1gb RAM running 23.09-DEVELOPMENT-amd64-20230909-1856

Actions #23

Updated by Christopher Cope about 1 year ago

Jordan G wrote in #note-22:

still seeing a negative number suggested for the higher limit on system with <1gb RAM running 23.09-DEVELOPMENT-amd64-20230909-1856

The new patches weren't merged in yet, should be in the next build.

New patches just merged.

Actions #24

Updated by Jim Pingle about 1 year ago

It's better but still quirky.

On a VM with 1GB RAM it says the default is 512 but the allowed range is 128 to 449, so there isn't a way to set the manual value as high as the default.

Actions #25

Updated by Jim Pingle about 1 year ago

  • Status changed from New to In Progress
  • Assignee changed from Christopher Cope to Jim Pingle
Actions #26

Updated by Jim Pingle about 1 year ago

  • Status changed from In Progress to Feedback
Actions #27

Updated by Jordan G about 1 year ago

23.09 on 6100, this looks better for default and range

Actions #28

Updated by aleksei prokofiev about 1 year ago

Tested on
23.09-RC (amd64)
built on Fri Oct 27 1:51:00 UTC 2023
FreeBSD 14.0-CURRENT
Looks good, in VM it is calculated based on available RAM
Also, I can setup max available value
4g

2g

1g

Actions #29

Updated by Jim Pingle about 1 year ago

  • Status changed from Feedback to Resolved
Actions #30

Updated by Jim Pingle about 1 year ago

  • Target version changed from 2.8.0 to 2.7.1
Actions #31

Updated by Jonathan Lee 12 months ago

What is recommended for SG-2100MAX with 23.05.01 in use I can't remember I was using 128 I think but you guys are showing 512 now half a gb?

Actions

Also available in: Atom PDF