Allowed memory size exhausted on get_users function.
-
Hi,
I’m having an issue where the
Hubwoo::hubwoo_get_total_contact_need_sync()
method is consistently triggering the following error:"Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes)"
I investigated the function and discovered that online 2765, the function fetches a count of all of the system users by fetching the entire
wp_users
table and then counting the resulting array.$unique_users = count( get_users() );
Our WP install has about 26,000 users, so it seems like the inefficiency of this method of counting unique users is what is potentially causing this error.
Can we please improve this function so that it’s scalable? It seems that a simple
$unique_users = (int) wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM $wpdb->users" ) );
would do the trick here with no scalability concerns.Thank you!
- The topic ‘Allowed memory size exhausted on get_users function.’ is closed to new replies.