# PHP Fatal Error: Out Of Memory dank EntityWrittenContainerEvent

**URL:** <https://forum.shopware.com/t/php-fatal-error-out-of-memory-dank-entitywrittencontainerevent/93008>\
**Category:** Shopware 6 (German)\
**Created:** [17. Februar 2022 um 17:45 UTC](https://forum.shopware.com/t/php-fatal-error-out-of-memory-dank-entitywrittencontainerevent/93008 "2022-02-17T17:45:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [17. Februar 2022 um 17:45 UTC](https://forum.shopware.com/t/php-fatal-error-out-of-memory-dank-entitywrittencontainerevent/93008/1 "2022-02-17T17:45:50Z")

</div>

Nachdem ein Import-Script eines Kunden mit Out Of Memory (4GB Limit) stets nach ungefähr 1200 Iterationen abbricht, habe ich mal versucht das Problem zu lokalisieren.

Das Problem liegt im Symfony EventDispatcher, der bei jeder Iteration 2MB mehr Memory konsumiert.  
Das macht er aber nur beim Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent. Bei anderen Events liegt der dauerhafte Memory-Konsum bei durchschnittlich 0,1 MB.

Hat jemand gleiche Probleme (gewiss, ggf. unwissend) oder hat sich diesem Thema schon einmal angenommen?

Das erklärt natürlich auch, wieso Importe generell Ewigkeiten dauern bzw. abbricht.

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [18. Februar 2022 um 09:34 UTC](https://forum.shopware.com/t/php-fatal-error-out-of-memory-dank-entitywrittencontainerevent/93008/2 "2022-02-18T09:34:47Z")

</div>

Ich habe mir die Listener im Detail angesehen…

```auto
Registered Listeners Grouped by Event
=====================================

"Shopware\Core\Framework\DataAbstractionLayer\Event\EntityWrittenContainerEvent" event
--------------------------------------------------------------------------------------

 ------- ------------------------------------------------------------------------------------------------------ ---------- 
  Order Callable Priority  
 ------- ------------------------------------------------------------------------------------------------------ ---------- 
  #1 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateSalutationRoute() 2016      
  #2 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateCountryRoute() 2015      
  #3 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateStreamIds() 2014      
  #4 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateStreamsBeforeIndexing() 2013      
  #5 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateSnippets() 2012      
  #6 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateShippingMethodRoute() 2011      
  #7 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateContext() 2010      
  #8 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateCrossSellingRoute() 2009      
  #9 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidatePropertyFilters() 2008      
  #10 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateManufacturerFilters() 2007      
  #11 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateProductAssignment() 2006      
  #12 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidatePaymentMethodRoute() 2005      
  #13 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateNavigationRoute() 2004      
  #14 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateLanguageRoute() 2003      
  #15 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateCurrencyRoute() 2002      
  #16 Shopware\Core\Framework\Adapter\Cache\CacheInvalidationSubscriber::invalidateCmsPageIds() 2001      
  #17 Shopware\Storefront\Framework\Routing\CachedDomainLoaderInvalidator::invalidate() 2000      
  #18 Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexerRegistry::refresh() 1000      
  #19 Shopware\Storefront\Framework\Seo\SeoUrlRoute\SeoUrlUpdateListener::detectSalesChannelEntryPoints() 0         
  #20 Shopware\Elasticsearch\Product\CustomFieldUpdater::onNewCustomFieldCreated() 0         
 ------- ------------------------------------------------------------------------------------------------------ ----------

```

Irgendeiner dieser Subscriber (oder includierte Scripts) konsumiert pro Iteration knapp 2 MB Speicher.

Ich habe gesehen, dass für 6.5.0.0 teile des Codes umgeschrieben wurden. Ich bin mir aber nicht sicher in wie weit es dieses durchaus ernsthafte Problem adressiert.

Könnt ihr dazu etwas sagen? @marco.steinhaeuser

---

<div class="post-metadata">

**Author:** ![marco.steinhaeuser](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/marco.steinhaeuser/32/14512_2.png) [@marco.steinhaeuser](https://forum.shopware.com/u/marco.steinhaeuser)\
**Post date:** [18. Februar 2022 um 15:10 UTC](https://forum.shopware.com/t/php-fatal-error-out-of-memory-dank-entitywrittencontainerevent/93008/3 "2022-02-18T15:10:21Z")

</div>

Puh, da fühle ich mich noch immer etwas nackt 🙂  
Schau mal, nach dem letzten Oktober ist hier vor vier Tagen etwas passiert, meinst Du diese Änderung? [History for src/Core/Framework/DataAbstractionLayer/Event/EntityWrittenContainerEvent.php - shopware/platform · GitHub](https://github.com/shopware/platform/commits/trunk/src/Core/Framework/DataAbstractionLayer/Event/EntityWrittenContainerEvent.php)

Im Commit sehe ich im Wesentlichen nur zwei neue public functions: [NEXT-20119 - Add product.written event when association deleted · shopware/platform@6479d7a · GitHub](https://github.com/shopware/platform/commit/6479d7a6bb52d43a8d556fd00f6e1b2c610b5491)

Pack das doch ansonsten gern mal mit in den Issue-Tracker. Ich könnte mir vorstellen, das solche konkreten Hinweise sehr dankbar aufgenommen werden.
