forms – Implementing hook_entity_type_build causes 500 error on cache clear


I recently attempted to display custom form modes based on the currently logged in user. My searching led me to implement hook_entity_type_build. However, I am finding that even just having this function declared with an empty body is causing an internal 500 error whenever I clear the cache using Devel > Cache Clear :

(Tue Sep 15 14:29:21.472533 2020) (php7:error) (pid 13440) (client address:port) PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 65536 bytes) in /path/to/drupal/core/includes/errors.inc on line 62, referer: http://example.com/node/123

My module has a couple other hooks implemented, but I’ve verified that adding / removing this empty function body to myModule.module directly causes / removes the crashes:

function myModule_entity_type_build(array &$entity_types){
      #causes crashes just by existing!
}

I’m still developing the site so it barely has any content on it at all… What in the world could cause an empty hook declaration to use so much memory (~500MB) on cache clear?? Any advice on where to look next is greatly appreciated!