---
title: "Site Factory installations fail when memcache is included"
date: "2022-02-25T00:50:29+00:00"
summary:
image:
type: "article"
url: "/site-factory/help/92251-site-factory-installations-fail-when-memcache-included"
id: "5dd2e781-4ae6-457a-9a4e-25e183f9edb1"
---

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

_Note_

_The error might not appear as such in the Site Factory logs if you have changed PHP's **error\_reporting** related settings (_[https://www.php.net/manual/en/errorfunc.configuration.php](https://www.php.net/manual/en/errorfunc.configuration.php)_)_

  
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..