Error: “Allowed memory size exhausted” when exporting entries
A GravityExport download link builds the whole file while the request is open. It reads every matching entry and builds every row and column in PHP’s memory before it sends the file. The memory and the time this takes grow with the number of entries times the number of columns, so a large form can use up PHP’s memory limit before the file is ready.
What the error looks like #
The download link opens a page headed GravityExport Lite: Something is broken. WordPress’s own message, “There has been a critical error on this website.”, may appear above it. Signed in as a user who can export entries, you also see the error message, such as “Allowed memory size of 268435456 bytes exhausted (tried to allocate 2097152 bytes)”. The first number is the memory limit in bytes: 268435456 bytes is 256 MB.

Anyone else who opens the link sees “The export could not be created. The reason was written to the server’s error log.” The stack trace below the message on the signed-in page lists only the handler that reported the error, so it doesn’t help find the cause.
A large export can also end in a timeout. GravityExport lifts PHP’s own time limit for a download, but your web server, your host or a service in front of the site, such as Cloudflare, stops waiting after a set time. The browser then shows a timeout or gateway error, or a page that keeps loading. Each fix below helps with both errors: it makes the file smaller or moves the work off the download link.
How much memory an export needs #
As a guide, an Excel file needs roughly 1.5 KB of memory for each cell, which is one entry in one column. On a test server, a form with 20,000 entries reached these peaks:
| Export | Peak memory | Time |
|---|---|---|
| All 20,000 entries, 32 columns, Excel | 841 MB | 57 seconds |
| All 20,000 entries, 32 columns, CSV | 582 MB | 55 seconds |
| One year (9,946 entries), 32 columns, Excel | 425 MB | 29 seconds |
| All 20,000 entries, 12 columns, Excel | 375 MB | 25 seconds |
With a 256 MB limit, the 12-column export of all entries failed, and the same columns for one year downloaded at 192 MB.
Export a smaller date range #
The date range is applied when GravityExport reads the entries, so a range with half the entries needs about half the memory. To download a range yourself:
- In your WordPress dashboard, go to Forms, hover over the form, and click Settings.
- Open the GravityExport tab.
- In the Instant Download section, enter the Start and End dates as
YYYY-MM-DD, and click Download.

For a download link you share, add the range to the link, for example ?start_date=2026-01-01&end_date=2026-03-31. See Filtering entries included in a GravityExport download for date ranges and field filters in the link. A form that is too large for one file can be exported in several, one range at a time.
Export fewer columns #
By default the download includes every form field and a set of entry properties, such as User Agent, Source Url and the payment columns, even when they are empty. On the same GravityExport tab, in Field settings, keep only the columns you need under Enabled Fields: click the × next to a field to move it to Disabled Fields, then click Save Settings.

In the test above, going from 32 columns to 12 cut the peak from 841 MB to 375 MB and the time from 57 to 25 seconds.
Download a CSV file instead of Excel #
A CSV file needs a quarter to a third less memory than an Excel file with the same rows. Choose .csv under File Extension in the Download settings section, or add .csv to the end of the download link. CSV helps less than a date range or fewer columns, because GravityExport still builds the whole file in memory.
Raise the PHP memory limit #
The download link runs as a normal page of your site, so it gets the memory limit WordPress sets for the front end. To raise it, add define( 'WP_MEMORY_LIMIT', '512M' ); to wp-config.php, above the line that reads / That's all, stop editing! Happy publishing. /. WordPress raises PHP’s limit to that value when the server allows it. WP_MAX_MEMORY_LIMIT is the separate limit WordPress raises for the dashboard, and download links stay at WP_MEMORY_LIMIT.
Some hosts cap PHP’s memory below what you set. If the error message still shows the old limit, ask your host to raise PHP’s memory_limit.
Run large exports on a schedule #
With GravityExport, a Save feed can create the file on a schedule and store it on your server, in Dropbox, Box or on an FTP server. When a scheduled run has more than 500 entries to export, GravityExport reads them 100 at a time in the background, and a CSV file is written as it goes. In the same test, a scheduled CSV export of all 20,000 entries stayed within a 256 MB limit. See How to schedule automated exports to set one up, and choose .csv as the File Extension on the feed’s File Settings tab.

An Excel file is still put together in one piece at the end of the run. Before it starts, GravityExport estimates the memory the file needs. When the file wouldn’t fit in the memory left, it stops the run and says so on the feed’s Activity Log tab:

Only scheduled runs are split up. Export Now on the feed list, the feed’s On-Demand Trigger URL and a webhook build the file in one request, the same way a download link does.