Issue
If you are using Site Factory with memcache, you might encounter memory exhaustion in the context of memcache during new site installations which would look like this:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 1990656 bytes) in /mnt/www/html/site.environment/docroot/modules/contrib/memcache/src/Driver/MemcachedDriver.php on line 17
Resolution
Removing memcache from your settings does resolve this but this is not always desirable (e.g. for production sites serving traffic). If you wish to keep memcache running, you should surround the code setting up memcache (it should be within your post-settings-php factory hooks) with a clause that looks like this:
if(!(PHP_SAPI === 'cli' && isset($_SERVER['argv']) && in_array('site-install',$_SERVER['argv']))){
// memcache settings
// and/or inclusions
// go here
}
This way memcache will not be enabled during drush site-install calls only..