Fixed setMemoryLimit does not increase memory limit when set to -1 (unlimited)

TickTackk

Well-known member
Unless I'm mistaken wouldn't the setMemoryLimit just return true and not actually update memory_limit if trying to update value to -1
PHP:
        $existingLimit = self::getMemoryLimit();
        if ($existingLimit < 0)
        {
            return true;
        }

        $limit = intval($limit);
        if ($limit > $existingLimit && $existingLimit)
        {
            if (@ini_set('memory_limit', $limit) === false)
            {
                return false;
            }

            self::$memoryLimit = $limit;
        }

        return true;
Edit: Switching it with

PHP:
        $existingLimit = self::getMemoryLimit();
        if ($existingLimit < 0)
        {
            return true;
        }

        $limit = intval($limit);
        if ($limit > $existingLimit && $existingLimit || $limit === -1)
        {
            if (@ini_set('memory_limit', $limit) === false)
            {
                return false;
            }

            self::$memoryLimit = $limit;
        }

        return true;
seems to have fixed it.
 
Last edited:

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.1.9).

Change log:
Properly support disabling memory limits when calling setMemoryLimit with -1.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top