Title: Allowed memory size exhausted on get_users function.
Last modified: October 23, 2023

---

# Allowed memory size exhausted on get_users function.

 *  Resolved [konstantinbrazhnik](https://wordpress.org/support/users/konstantinbrazhnik/)
 * (@konstantinbrazhnik)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/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!

Viewing 1 replies (of 1 total)

 *  Plugin Author [MakeWebBetter](https://wordpress.org/support/users/makewebbetter/)
 * (@makewebbetter)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/allowed-memory-size-exhausted-on-get_users-function/#post-17152426)
 * Hello,
   Thank you for sharing this concern. In our upcoming update, we will resolve
   this concern.

Viewing 1 replies (of 1 total)

The topic ‘Allowed memory size exhausted on get_users function.’ is closed to new
replies.

 * ![](https://ps.w.org/makewebbetter-hubspot-for-woocommerce/assets/icon-128x128.
   png?rev=2294178)
 * [MWB HubSpot for WooCommerce - CRM, Abandoned Cart, Email Marketing, Marketing Automation & Analytics](https://wordpress.org/plugins/makewebbetter-hubspot-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/makewebbetter-hubspot-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/makewebbetter-hubspot-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/makewebbetter-hubspot-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/makewebbetter-hubspot-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/makewebbetter-hubspot-for-woocommerce/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [MakeWebBetter](https://wordpress.org/support/users/makewebbetter/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/allowed-memory-size-exhausted-on-get_users-function/#post-17152426)
 * Status: resolved