XF 2.1 Allowed memory size of 134217728 bytes exhausted (tried to allocate 40960 bytes)

TickTackk

Well-known member
When upgrading to 2.1.8 from 2.1.7 via CLI I receive these errors
Code:
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 40960 bytes) in <xf path>/src/XF/Db/Mysqli/Statement.php on line 125

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 40960 bytes) in <xf path>/src/XF/Db/Mysqli/Statement.php on line 125
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in <xf path>/src/XF/Error.php on line 1

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in <xf path>/src/XF/Error.php on line 1

There is no source being shown so I had to do classic echo/print to figure out why and turns out the problem is being here src\XF\AddOn\DataType\StyleProperty.php:68. Running a quick:
SQL:
SELECT COUNT(*)
FROM xf_style_property
WHERE style_id = 0
returns 259.

Running XF in a VM which has 1GB memory.
 
Last edited:
I don't recall us making any changes in this area and while you pointed us to line 68 I'm not really seeing anything there that should cause this.

I'm concerned that perhaps you've not tracked it down to the right source.

What is the full output if you add -vvv to the upgrade command?
 
The number of styles you have shouldn't make a difference to the code you have pointed out so far. The particular code you pointed out only enumerates the style properties in style_id 0 that exist in the style property XML files.

Adding -vvv would usually provide a full stack trace, though I appreciate with it being a fatal error that might not come through.

It's possible that there is something somewhere that isn't running optimally in the process with that number of styles/properties but I don't think it's that specific code.
 
Right, but how would performing that query (from Line 68) which only returns a minimal number of records cause 128MB of memory usage?
 
@Chris D After debugging even the memory issue is being caused in src/XF/DesignerOutput/StyleProperty.php:getLessCacheFileValue, more specifically this
PHP:
        $finder = \XF::finder('XF:StyleProperty')
            ->with('Style', true)
            ->where([
                'Style.designer_mode' => $designerMode
            ])
            ->order('property_name');
        $properties = $finder->fetch();
After setting memory_limit to -1 and then checking the memory usage $properties has been defined is 165675008 (165MB) from \memory_get_usage(true).
 
It's worth mentioning that we actually set the memory_limit to -1 in the CLI runner class already, so I'm not sure if that is something that you were potentially overriding in config.php.
 
In file /<xf root>/src/XF.php search for
PHP:
        if ($limit > $existingLimit && $existingLimit)
and replace with:
PHP:
        if ($limit > $existingLimit && $existingLimit || $limit === -1)
 
Actually, after reading your post we are not having the same issue. I was facing issue when upgrading to 2.1.8 (non PL) via CLI whereas you're getting error when editing the less template.

Sorry about wasting your time haha.
 
Back
Top Bottom