SMF 2.0.17 - Why does Subs-Graphics.php reduce memory limit to 90M?

Started by GL700Wing, September 14, 2020, 12:07:17 AM

Previous topic - Next topic

GL700Wing

I've been working an an update to the Automatic Attachment Rotation (and Resize) mod and one of the things I discovered is that in the resizeImageFile function in ./Sources/Subs-Graphics.php the PHP memory limit is set to 90M and I'm just wondering why this is done when the PHP memory limit is set to 128M in ./index.php.

If the PHP memory limit wasn't reduced in this function I, along with many others, probably wouldn't need to install the Image Processing Memory Limit mod which, ironically, adds code to the resizeImageFile function to enable the PHP memory limit to be increased (the default value for this mod is 128M).

Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

I've run into memory limit problems on a couple of forums, fixed them by finding all occurrences of memory_limit in core code and increasing all to 512mb.  Fixed the problems without any ill effects, no idea if it creates a performance hit, but doubt it.  May not be an entirely bad idea to create a mod that does this.

All instances of memory_limit in core code -

index.php (1 hit)
\Sources\Admin.php (2 hits)
\Sources\Class-Package.php (1 hit)
\Sources\DumpDatabase.php (2 hits)
\Sources\Packages.php (1 hit)
\Sources\RepairBoards.php (1 hit)
\Sources\Reports.php (1 hit)
\Sources\Subs-Graphics.php (1 hit)
\Sources\Subs-Members.php (2 hits)
\Sources\Subs-Package.php (3 hits)
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

shawnb61

Quote from: GL700Wing on September 14, 2020, 12:07:17 AM
If the PHP memory limit wasn't reduced in this function I, along with many others, probably wouldn't need to install the Image Processing Memory Limit mod which, ironically, adds code to the resizeImageFile function to enable the PHP memory limit to be increased (the default value for this mod is 128M).

Good question.  The admin.php one actually sets it to 32...

Have you confirmed that removing or changing Subs-Graphics limitation eliminates the need for Image Processing Memory Limit?  Would be worth a test...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

GL700Wing

Quote from: shawnb61 on September 14, 2020, 01:48:01 PM
Quote from: GL700Wing on September 14, 2020, 12:07:17 AM
If the PHP memory limit wasn't reduced in this function I, along with many others, probably wouldn't need to install the Image Processing Memory Limit mod which, ironically, adds code to the resizeImageFile function to enable the PHP memory limit to be increased (the default value for this mod is 128M).
Good question.  The admin.php one actually sets it to 32...
I know Admin.php sets it to 32Mb (and DumpDatabase.php sets it to 256Mb) but it seems to be the value set in index.php that applies when Subs-Graphics.php is called (this can be confirmed by printing out the results of  ini_get('memory_limit')  in Subs-Graphics.php prior to the memory limit being reduced).

That said, the value set by index.php doesn't take into account the configured memory limit (eg, the limit set within cPanel or via php.ini).

QuoteHave you confirmed that removing or changing Subs-Graphics limitation eliminates the need for Image Processing Memory Limit?  Would be worth a test...
Yes I have - definitely no problems attaching 12MP photos taken with my mobile phone and, based on my calculations, 16MP photos should also attach without any problems.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Advertisement: