#56628 closed enhancement (fixed)
Cron memory limit is unnecessarily low
Reported by: | iandunn | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | 2.1 |
Component: | Cron API | Keywords: | has-patch add-to-field-guide |
Focuses: | Cc: |
Description
Problem
wp-cron.php
uses the default WP_MEMORY_LIMIT
, which is sometimes low enough that a cron job triggers an out-of-memory error.
In many of those cases, the amount of memory needed is greater than WP_MEMORY_LIMIT
, but less than WP_MAX_MEMORY_LIMIT
, and all a dev has to do is call wp_raise_memory_limit( 'admin' )
in their cron callback.
That still requires time debugging and fixing, though, and Core could prevent those types of errors from happening in the first place.
Proposed Solution
Since crons often consume extra memory by nature, I think it makes sense to give them the full amount available by default. We already do this with the admin area and image processing.
That could be done by adding a new cron
context to wp_raise_memory_limit()
, and calling wp_raise_memory_limit( 'cron' )
in wp-cron.php
Attachments (1)
Change History (7)
#1
@
2 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
#3
@
2 years ago
I haven't tested it yet, but the code for 56628.patch looks good, thanks Hardik!
It doesn't look like `wp_raise_memory_limit()` is very testable, so addition tests probably aren't needed here.
Do any component maintainers or committers have an opinion on this ticket? I don't work with the Cron internals much, so I want to make sure I'm not missing something.
Hi @iandunn , I've added an initial patch for your above suggested changes.