Reduce memory utilization when syncing/removing members from large groups
adamfranco opened this issue · 0 comments
adamfranco commented
Currently full user-data is loaded for each member even if only the display name or ID is needed. This can inflate the memory utilization when syncing extremely large groups.
-
get_userdata( int $user_id ): [WP_User](https://developer.wordpress.org/reference/classes/wp_user/)|false
which is called on removal returns a user object when all we need is the display name string. -
On addition we're calling
getOrCreateUser()
which is also returning a user object when we need the ID and maybe a display name.
There are two possible tracks:
- Load only the user id and display_name as needed, not the full user object.
- Unload the user object in a way that frees its memory each cycle of the loop.