Title: cron_memory_limit
Published: August 8, 2023
Last modified: February 24, 2026

---

# apply_filters( ‘cron_memory_limit’, int|string $filtered_limit )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#wp--skip-link--target)

Filters the memory limit allocated for WP-Cron event processing.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#parameters)󠁿

 `$filtered_limit`int|string

Maximum memory limit to allocate for WP-Cron.
 Default `WP_MAX_MEMORY_LIMIT` or 
the original php.ini `memory_limit`, whichever is higher. Accepts an integer (bytes),
or a shorthand string notation, such as `'256M'`.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#source)󠁿

    ```php
    $filtered_limit = apply_filters( 'cron_memory_limit', $filtered_limit );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L7910)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L7910-L7910)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_raise_memory_limit()](https://developer.wordpress.org/reference/functions/wp_raise_memory_limit/)`wp-includes/functions.php` |

Attempts to raise the PHP memory limit for memory intensive processes.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/cron_memory_limit/?output_format=md#comment-content-6617)
 2.   [Huzaifa Al Mesbah](https://profiles.wordpress.org/huzaifaalmesbah/)  [  3 years ago  ](https://developer.wordpress.org/reference/hooks/cron_memory_limit/#comment-6617)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fcron_memory_limit%2F%23comment-6617)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fcron_memory_limit%2F%23comment-6617)
 4.     ```php
        // This is your callback function that adjusts the memory limit for cron tasks
        function wpdocs_cron_memory_limit( $limit ) {
            // You can modify the memory limit based on your requirements
            // For this example, let's increase the limit by 128M
            if ( is_numeric( $limit ) ) {
                $new_limit = $limit + 128;
                return $new_limit;
            }
    
            return $limit;
        }
    
        // Hook your custom function to the 'cron_memory_limit' filter
        add_filter( 'cron_memory_limit', 'wpdocs_cron_memory_limit' );
    
        // Somewhere in your code where you need to retrieve the adjusted memory limit
        $memory_limit = apply_filters( 'cron_memory_limit', ini_get( 'memory_limit' ) );
    
        echo 'Adjusted memory limit for cron tasks: ' . $memory_limit;
        ```
    
 5. In this example, we’re assuming you are working within a WordPress environment 
    and you want to adjust the memory limit for cron tasks. The `apply_filters` function
    allows you to apply a series of filters to a specific value, in this case, the 
    memory limit. The `custom_cron_memory_limit` function acts as a filter callback,
    adjusting the memory limit by adding 128M to it.
 6. When you call `apply_filters('cron_memory_limit', ini_get('memory_limit'))` WordPress
    will execute your custom function and pass the current memory limit value as an
    argument. Your function will then modify the limit and return the adjusted value,
    which will be used wherever the `apply_filters` function is called. Finally, the
    adjusted memory limit is echoed out in the example.
 7.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fcron_memory_limit%2F%3Freplytocom%3D6617%23feedback-editor-6617)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fcron_memory_limit%2F)
before being able to contribute a note or feedback.