# Memory Limit CronJob

**URL:** https://forum.shopware.com/t/memory-limit-cronjob/92448
**Category:** Shopware 6 (German)
**Tags:** programming
**Created:** [20. Januar 2022 um 07:27 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448 "2022-01-20T07:27:47Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Drommbart](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@Drommbart](https://forum.shopware.com/u/Drommbart)
#### Post date: [20. Januar 2022 um 07:27 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/1 "2022-01-20T07:27:47Z")

</div>

Grüße ich bekomme immer eine Memory Limit Fehler angezeigt.  
Folgende Einstellungen wurden vorgenommen.

Cronjob alle 5 Minuten  
#!/bin/bash  
php /home/www/p579281/html/shopware/bin/console messenger:consume default --time-limit=360 --memory-limit=512M  
php /home/www/p579281/html/shopware/bin/console scheduled-task:run --time-limit=60

php.ini  
memory\_limit = 1024M (Wurde von unserem Webhorst so eingestellt)  
post\_max\_size = 512M  
upload\_max\_filesize = 512M

Das hat dann genau 1x funktioniert.

[OK] Consuming messages from transports „default“.

// The worker will automatically exit once it has exceeded 1020 of memory, been  
// running for 360s or received a stop signal via the messenger:stop-workers  
// command.

// Quit the worker with CONTROL-C.

13:35:02 INFO [messenger] Received message Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask [„message“ =\> Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask { …},„class“ =\> „Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask“]  
13:35:03 INFO [app] cache-miss: context-factory-696edab409aa400e9f76e95471bdc8ed  
13:35:03 INFO [messenger] Message Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask handled by Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTaskHandler::\_\_invoke [„message“ =\> Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask { …},„class“ =\> „Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask“,„handler“ =\> „Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTaskHandler::\_\_invoke“]  
13:35:03 INFO [messenger] Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask was handled successfully (acknowledging to transport). [„message“ =\> Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask { …},„class“ =\> „Shopware\Core\Content\ProductExport\ScheduledTask\ProductExportGenerateTask“]  
13:35:03 INFO [messenger] Worker stopped due to memory limit of 1020 bytes exceeded (48758784 bytes used) [„limit“ =\> 1020,„memory“ =\> 48758784]

Jetzt gibt es alle 5 Minuten die Meldung

[OK] Consuming messages from transports „default“.

// The worker will automatically exit once it has exceeded 512M of memory, been  
// running for 360s or received a stop signal via the messenger:stop-workers  
// command.

// Quit the worker with CONTROL-C.

// Re-run the command with a -vv option to see logs about consumed messages.

07:10:19 CRITICAL [php] Fatal Error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 479232 bytes) [„exception“ =\> Symfony\Component\ErrorHandler\Error\OutOfMemoryError { …}]

In PDOStatement.php line 262:

Error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate  
479232 bytes)

messenger:consume [-l|–limit LIMIT] [-f|–failure-limit FAILURE-LIMIT] [-m|–memory-limit MEMORY-LIMIT] [-t|–time-limit TIME-LIMIT] [–sleep SLEEP] [-b|–bus BUS] [–queues QUEUES] [–] […]

Scheduled task runner stopped due to time limit of 60s reached

Ich verstehe denn Zusammenhang nicht. Das es genau einmal funktioniert und danach nie wieder.  
Sollte es keine Lösung geben. Wie schalte ich den Admin Worker wieder ein?

---

<div class="post-metadata">

### Author: ![greitmann-design](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/greitmann-design/32/25880_2.png) [@greitmann-design](https://forum.shopware.com/u/greitmann-design)
#### Post date: [21. Februar 2022 um 19:45 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/2 "2022-02-21T19:45:16Z")

</div>

Hallo Drommbart,

bei mir dasselbe Problem. Egal wie hoch ich das Memory-Limit einstelle, es läuft immer voll. Auch mit angebundenem RabbitMQ dasselbe. Bin mittlerweile etwas ratlos.

---

<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: [22. Februar 2022 um 11:47 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/3 "2022-02-22T11:47:52Z")

</div>

Der Admin Worker erzeugt den gleichen Fehler. Nur da bekommst du keine Fehlermeldung zu sehen (bei Cronjob-Fehler versenden die meisten Hoster eine E-Mail).

Das Problem ist ein EventDispatcher, der pro Iteration Speicher konsumiert aber nicht wieder freigibt. Habe dazu einen Forumsbeitrag die Tage geschrieben.

---

<div class="post-metadata">

### Author: ![pascal.kolp](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@pascal.kolp](https://forum.shopware.com/u/pascal.kolp)
#### Post date: [4. März 2022 um 12:32 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/4 "2022-03-04T12:32:12Z")

</div>

Hallo Max\_Shop

Es scheint bei uns ein ähnliches Problem zu geben mit dem `ProductExportGenerateTask`. Unsere Serverlast ist nach dem Update auf 6.4.8.1 um ein vielfaches gestiegen. Vor allem mit diesem Select:  
SELECT `category`.`id` as `category.id`, `category`.`version_id` as `category.versionId`, `category`.`parent_id` as `category.parentId`, `category`.`parent_version_id` as `category.parentVersionId`, `category`.`after_category_id` as `category.afterCategoryId`, `category`.`after_category_version_id` as `category.afterCategoryVersionId`, `category`.`media_id` as `category.mediaId`, `category`.`display_nested_products` as `category.displayNestedProducts`, `category`.`auto_increment` as `category.autoIncrement`, `category`.`level` as `category.level`, `category`.`path` as `category.path`, `category`.`child_count` as `category.childCount`, `category`.`type` as `category.type`, `category`.`product_assignment_type` as `category.productAssignmentType`, `category`.`visible` as `category.visible`, `category`.`active` as `category.active`, `category`.`cms_page_id` as `category.cmsPageId`, `category`.`cms_page_version_id` as `category.cmsPageVersionId`, `category`.`product_stream_id` as `category.productStreamId`, `category`.`created_at` as `category.createdAt`, `category`.`updated_at` as `category.updatedAt`, `category.translation.name`, COALESCE(`category.translation.name`,`category.translation.name`) as `category.name`, `category.translation.breadcrumb`, COALESCE(`category.translation.breadcrumb`,`category.translation.breadcrumb`) as `category.breadcrumb`, `category.translation.slotConfig`, COALESCE(`category.translation.slotConfig`,`category.translation.slotConfig`) as `category.slotConfig`, `category.translation.linkType`, COALESCE(`category.translation.linkType`,`category.translation.linkType`) as `category.linkType`, `category.translation.internalLink`, COALESCE(`category.translation.internalLink`,`category.translation.internalLink`) as `category.internalLink`, `category.translation.externalLink`, COALESCE(`category.translation.externalLink`,`category.translation.externalLink`) as `category.externalLink`, `category.translation.linkNewTab`, COALESCE(`category.translation.linkNewTab`,`category.translation.linkNewTab`) as `category.linkNewTab`, `category.translation.description`, COALESCE(`category.translation.description`,`category.translation.description`) as `category.description`, `category.translation.metaTitle`, COALESCE(`category.translation.metaTitle`,`category.translation.metaTitle`) as `category.metaTitle`, `category.translation.metaDescription`, COALESCE(`category.translation.metaDescription`,`category.translation.metaDescription`) as `category.metaDescription`, `category.translation.keywords`, COALESCE(`category.translation.keywords`,`category.translation.keywords`) as `category.keywords`, `category.translation.customFields`, COALESCE(`category.translation.customFields`,`category.translation.customFields`) as `category.customFields`, `category.translation.createdAt`, `category.translation.updatedAt`, `category.translation.categoryId`, `category.translation.languageId`, `category.translation.categoryVersionId` FROM `category` LEFT JOIN (SELECT `category.translation`.category\_id, `category.translation`.category\_version\_id, `[category.translation`.name]([http://category.translation](http://category.translation)%60.name/) as `category.translation.name`, `category.translation`.breadcrumb as `category.translation.breadcrumb`, `category.translation`.slot\_config as `category.translation.slotConfig`, `category.translation`.link\_type as `category.translation.linkType`, `category.translation`.internal\_link as `category.translation.internalLink`, `category.translation`.external\_link as `category.translation.externalLink`, `category.translation`.link\_new\_tab as `category.translation.linkNewTab`, `category.translation`.description as `category.translation.description`, `category.translation`.meta\_title as `category.translation.metaTitle`, `category.translation`.meta\_description as `category.translation.metaDescription`, `category.translation`.keywords as `category.translation.keywords`, `category.translation`.custom\_fields as `category.translation.customFields`, `category.translation`.created\_at as `category.translation.createdAt`, `category.translation`.updated\_at as `category.translation.updatedAt`, `category.translation`.category\_id as `category.translation.categoryId`, `category.translation`.language\_id as `category.translation.languageId`, `category.translation`.category\_version\_id as `category.translation.categoryVersionId` FROM `category_translation` `category.translation` WHERE `category.translation`.language\_id = ‚/\_\<9A\>MpXT|^K‘) `category.category_translation` ON `category.category_translation`.`category_id` = `category`.`id` AND `category.category_translation`.category\_version\_id = `category`.version\_id WHERE (`category`.`version_id` = ‚^O^\<E3\>jK¾Ku,4%‘) AND ((`category`.`id` = ‚I^G^L\<M\<8C\>$h^Q^B‘)

Kannst du uns hier weiterhelfen?

Beste Grüsse

Pascal

---

<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: [4. März 2022 um 12:55 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/5 "2022-03-04T12:55:38Z")

</div>

Eine SQL-Abfrage sollte eigentlich kein großes Problem darstellen. Einfach mal über phpMyAdmin oder ähnlich die Query selbst testen und schauen, wie viele ms sie benötigt. Das Problem wird viel mehr die Weiterverarbeitung der Daten sein, schätze ich.

Sorry, da muss Shopware ran. Das ist ein Problem, dass tief im Core steckt.

---

<div class="post-metadata">

### Author: ![eierund](https://avatars.discourse-cdn.com/v4/letter/e/e8c25b/32.png) [@eierund](https://forum.shopware.com/u/eierund)
#### Post date: [12. April 2022 um 11:28 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/6 "2022-04-12T11:28:35Z")

</div>

Ich schließe mich hier mal an. Cronjobs funktionieren nicht und laufen voll.  
Selbst wenn ich den Speicher auf 16GB setze… ändert nichts.

Gibt es denn schon Neuigkeiten zu diesem Thema?

---

<div class="post-metadata">

### Author: ![Marc\_E](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Marc\_E](https://forum.shopware.com/u/Marc_E)
#### Post date: [12. Juli 2023 um 08:39 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/7 "2023-07-12T08:39:42Z")

</div>

Schließe mich auch an. Gibts es ein Jahr später Neuigkeiten?

---

<div class="post-metadata">

### Author: ![dein-bau-projekt](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@dein-bau-projekt](https://forum.shopware.com/u/dein-bau-projekt)
#### Post date: [12. Juli 2023 um 09:16 UTC](https://forum.shopware.com/t/memory-limit-cronjob/92448/8 "2023-07-12T09:16:45Z")

</div>

Ich kann da nicht wirklich etwas neues beitragen.  
Außer das der Vorgang ein absoluter Ram Fresser ist.

[product.indexer]  
33871/33871 [============================] 100% 10 mins/10 mins 5.9 GiB

Also ich habe jetzt 8 GB eingestellt. Mein Hoster macht das aber auch mit. Die meisten Begrenzen das.  
Auch würde ich empfehlen. Folgendes Plugin zu installieren.

> **[Tools](https://store.shopware.com/frosh12599847132f/tools.html)**
>
> Dieses Plugin enthält einige nützliche Funktionen für die Verwaltung eines Shopware 6 Shops. Der aktuelle Funktionsumfang besteht aus:…

Hier kann man sehen wie viel RAM freigegeben ist und noch ein paar andere Dinge.  
Die php.ini ist bei mir 2mal vorhanden. Eine von beiden hat nur keine Funktion mehr. Überprüf einmal ob deine Einstellungen auch wirklich verwendet werden.
