Out of memory issue with regions enabled

I have a large directory site (about 40,000 listings and importing 10K more slowly). Fairly good size VPS - 8 Core 24GB Ram.

I have done some extra Database optimizations… tuning Mariadb and adding additional indexes (needed badly for bigger directories).

I have the PHP memory_limit set to 2048M.

I still notice an occasional “Critical Error” crash when I visit a listing or region, etc. I turned on debug over the weekend and see a handful of these on each day:
[14-Dec-2025 17:49:35 UTC] PHP Fatal error: Out of memory (allocated 975175680 bytes) (tried to allocate 655360 byte s) in /home/barkparkfinder.com/public_html/wp-content/plugins/hivepress/includes/fields/class-select.php on line 170
[14-Dec-2025 17:55:00 UTC] PHP Fatal error: Out of memory (allocated 970981376 bytes) (tried to allocate 655360 byte s) in /home/barkparkfinder.com/public_html/wp-includes/meta.php on line 1196
[14-Dec-2025 17:57:41 UTC] PHP Fatal error: Out of memory (allocated 970981376 bytes) (tried to allocate 655360 byte s) in /home/barkparkfinder.com/public_html/wp-includes/meta.php on line 1196
[14-Dec-2025 18:48:34 UTC] PHP Fatal error: Out of memory (allocated 981467136 bytes) (tried to allocate 655360 byte s) in /home/barkparkfinder.com/public_html/wp-content/plugins/hivepress/includes/fields/class-select.php on line 170
[14-Dec-2025 21:49:22 UTC] PHP Fatal error: Out of memory (allocated 1010827264 bytes) (tried to allocate 20480 byte s) in /home/barkparkfinder.com/public_html/wp-content/plugins/hivepress/includes/components/class-form.php on line 29 3
[14-Dec-2025 21:52:52 UTC] PHP Fatal error: Out of memory (allocated 970981376 bytes) (tried to allocate 327680 byte s) in /home/barkparkfinder.com/public_html/wp-includes/class-wp-object-cache.php on line 406

I also see a lot of these entries though I am not sure they are related or a separate issue:
[15-Dec-2025 18:29:24 UTC] PHP Warning: Attempt to read property “taxonomy” on null in /home/barkparkfinder.com/public_html/wp-content/plugins/hivepress/includes/components/class-attribute.php on line 313
[15-Dec-2025 18:29:24 UTC] PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /home/barkparkfinder.com/public_html/wp-content/plugins/hivepress/includes/components/class-attribute.php on line 313

I’m worried about just throwing a band-aid on it and raising the PHP limit even higher, has anyone ran into this?

Thanks for reporting this, I added 2 last warnings to the bug tracker and these will be fixed in the next update.

I also checked the referenced code in the “out of memory” errors and it seems that these are caused by select fields with too many options, are there any fields like this (maybe drop-down fields with many options like locations)? We also plan to make an improvement to resolve this by loading options via AJAX if the number of options exceeds a sensible limit.

It happens on random pages and I’ve had it happen on the home page, single listing pages, region pages, etc, in the past.

Take a look at the site itself: https://www.barkparkfinder.com

The only select field on the homepage is: _category
And I have no categories at all actually so it’s blank.

I see no select fields on single listing pages. On the regions pages I see the _category field and the _sort field so very small there.

I do have two code snippets that add the 50 states (Regions) and Top 50 cities that you see at the bottom but those used cache transients so should be ok?

Here’s the code I use for the States: State Shortcode · GitHub

Here’s the code I use for the top 50 cities: Top 50 Cities · GitHub

Please let me know how many regions are already generated in Listings/Regions, I assume this has something to do with the Regions field (it’s a hidden select field, loaded even if not rendered).

That makes sense… I have 13,876 regions :slight_smile:

Thanks, then this is definitely the reason, we’ll release a fix for Select fields that would prevent loading the full list of options – I can also check if there’s a temporary fix until the official release, let me know if it’s needed.

1 Like

Yes, a temporary fix would be greatly needed and appreciated. Just let me know, thanks.

Please try this code snippet, it prevents loading regions per listing on the front-end, but still keeps the region-based search functional:

add_filter(
	'hivepress/v1/models/listing/attributes',
	function( $attributes ) {
		if ( ( ! is_admin() && ! hivepress()->helper->is_rest() ) && isset( $attributes['region'] ) ) {
			$attributes['region']['edit_field']['options']   = [];
			$attributes['region']['search_field']['options'] = [];
		}

		return $attributes;
	},
	1000
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.