Allowed memory size exhausted on category save Magento 2Fatal error: Allowed memory size of 134217728 bytes exhausted (tried > to allocate 4194304 bytes)Fatal error: Allowed memory size of 1073741824 bytes exhaustedHigh memory usage of parent categories collectionFatal error: Allowed memory size on php 5.6.3Memory size exhausted when switching store viewsFatal error: Allowed memory sizeAllowed memory size of 536870912 bytes exhaustedCategory with 20000 product not saveFatal error: Allowed memory size of 805306368 bytes exhausted

Unreachable code, but reachable with exception

Sword in the Stone story where the sword was held in place by electromagnets

Why doesn't the EU now just force the UK to choose between referendum and no-deal?

Happy pi day, everyone!

Why must traveling waves have the same amplitude to form a standing wave?

Dot in front of file

Does splitting a potentially monolithic application into several smaller ones help prevent bugs?

Identifying the interval from A♭ to D♯

Can anyone tell me why this program fails?

Replacing Windows 7 security updates with anti-virus?

Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere

Have researchers managed to "reverse time"? If so, what does that mean for physics?

Make a transparent 448*448 image

Theorems like the Lovász Local Lemma?

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

Could the Saturn V actually have launched astronauts around Venus?

RegionDifference for Cylinder and Cuboid

Professor being mistaken for a grad student

How to deal with taxi scam when on vacation?

Will a pinhole camera work with instant film?

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

Do I need life insurance if I can cover my own funeral costs?

Meaning of "SEVERA INDEOVI VAS" from 3rd Century slab



Allowed memory size exhausted on category save Magento 2


Fatal error: Allowed memory size of 134217728 bytes exhausted (tried > to allocate 4194304 bytes)Fatal error: Allowed memory size of 1073741824 bytes exhaustedHigh memory usage of parent categories collectionFatal error: Allowed memory size on php 5.6.3Memory size exhausted when switching store viewsFatal error: Allowed memory sizeAllowed memory size of 536870912 bytes exhaustedCategory with 20000 product not saveFatal error: Allowed memory size of 805306368 bytes exhausted













0















I'm trying to to enable the "Anchor" flag on a category with about 1400 products. When I click save, the page loads for a very long time (about 45 minutes) and finally gives me an internal server error 500.



I tried the same with a category with about 500 products, there it worked after about 20 minutes (still much too long but no error).



I get the following error in the php error log:




PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 33554440 bytes) in /Users/myuser/Sites/myproject/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 3551




PHP settings:



memory_limit = 1024M # in .user.ini
max_execution_time = 18000 # in .user.ini
post_max_size = 32M
max_input_vars = 100000


MySQL Settings:



max_allowed_packet = 1024M
wait_timeout = 180


Environment:



Installation: MAMP PRO
PHP-Version: 7.0.8.


Magento Settings:



  • Version: 2.1.7

  • All indexes are set to "UPDATE BY SCHEDULE" and were run

  • Use flat category: YES (also tried with NO)

  • Use flat product: YES (also tried with NO)

  • Caches are cleared

  • Tried clearing /var/generation folder

So basically, I tried everything I could find on the internet but nothing seemed to help. Of course I can now try to set memory_limit to 2056 but then it needs like 2 hours - I don't think that's a solution.



What can I do?










share|improve this question














bumped to the homepage by Community 19 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.



















    0















    I'm trying to to enable the "Anchor" flag on a category with about 1400 products. When I click save, the page loads for a very long time (about 45 minutes) and finally gives me an internal server error 500.



    I tried the same with a category with about 500 products, there it worked after about 20 minutes (still much too long but no error).



    I get the following error in the php error log:




    PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 33554440 bytes) in /Users/myuser/Sites/myproject/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 3551




    PHP settings:



    memory_limit = 1024M # in .user.ini
    max_execution_time = 18000 # in .user.ini
    post_max_size = 32M
    max_input_vars = 100000


    MySQL Settings:



    max_allowed_packet = 1024M
    wait_timeout = 180


    Environment:



    Installation: MAMP PRO
    PHP-Version: 7.0.8.


    Magento Settings:



    • Version: 2.1.7

    • All indexes are set to "UPDATE BY SCHEDULE" and were run

    • Use flat category: YES (also tried with NO)

    • Use flat product: YES (also tried with NO)

    • Caches are cleared

    • Tried clearing /var/generation folder

    So basically, I tried everything I could find on the internet but nothing seemed to help. Of course I can now try to set memory_limit to 2056 but then it needs like 2 hours - I don't think that's a solution.



    What can I do?










    share|improve this question














    bumped to the homepage by Community 19 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

















      0












      0








      0


      1






      I'm trying to to enable the "Anchor" flag on a category with about 1400 products. When I click save, the page loads for a very long time (about 45 minutes) and finally gives me an internal server error 500.



      I tried the same with a category with about 500 products, there it worked after about 20 minutes (still much too long but no error).



      I get the following error in the php error log:




      PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 33554440 bytes) in /Users/myuser/Sites/myproject/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 3551




      PHP settings:



      memory_limit = 1024M # in .user.ini
      max_execution_time = 18000 # in .user.ini
      post_max_size = 32M
      max_input_vars = 100000


      MySQL Settings:



      max_allowed_packet = 1024M
      wait_timeout = 180


      Environment:



      Installation: MAMP PRO
      PHP-Version: 7.0.8.


      Magento Settings:



      • Version: 2.1.7

      • All indexes are set to "UPDATE BY SCHEDULE" and were run

      • Use flat category: YES (also tried with NO)

      • Use flat product: YES (also tried with NO)

      • Caches are cleared

      • Tried clearing /var/generation folder

      So basically, I tried everything I could find on the internet but nothing seemed to help. Of course I can now try to set memory_limit to 2056 but then it needs like 2 hours - I don't think that's a solution.



      What can I do?










      share|improve this question














      I'm trying to to enable the "Anchor" flag on a category with about 1400 products. When I click save, the page loads for a very long time (about 45 minutes) and finally gives me an internal server error 500.



      I tried the same with a category with about 500 products, there it worked after about 20 minutes (still much too long but no error).



      I get the following error in the php error log:




      PHP Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 33554440 bytes) in /Users/myuser/Sites/myproject/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 3551




      PHP settings:



      memory_limit = 1024M # in .user.ini
      max_execution_time = 18000 # in .user.ini
      post_max_size = 32M
      max_input_vars = 100000


      MySQL Settings:



      max_allowed_packet = 1024M
      wait_timeout = 180


      Environment:



      Installation: MAMP PRO
      PHP-Version: 7.0.8.


      Magento Settings:



      • Version: 2.1.7

      • All indexes are set to "UPDATE BY SCHEDULE" and were run

      • Use flat category: YES (also tried with NO)

      • Use flat product: YES (also tried with NO)

      • Caches are cleared

      • Tried clearing /var/generation folder

      So basically, I tried everything I could find on the internet but nothing seemed to help. Of course I can now try to set memory_limit to 2056 but then it needs like 2 hours - I don't think that's a solution.



      What can I do?







      magento-2.1 fatal-error memory magento-2.1.7






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 7 '17 at 14:00









      msblrmsblr

      1686




      1686





      bumped to the homepage by Community 19 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 19 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The issue is related to the new way of URL rewrites generator in Magento2. In Magento2, URL rewrites are generated (in url_rewrite table) when user save the category. If you have a complex category structure and assign a category as child of multiple parents or using categories across different store_views , it tries to generate the URL for all combinations and hence get out of memory.



          Here are some links I'd recommend you to go through so you might found a solution for your problem.



          https://github.com/magento/magento2/issues/9706



          https://github.com/magento/magento2/issues/10242



          This is not a solution but a workaround.



          I had also face the same issue with after migrating a huge Magento1 site. Here is the hack down there that is not a solution but it can confirm the issue for you. Update the following core file for instance and then try to update the category name.




          M2vendormagentomodule-catalog-url-rewriteObserverCategoryProcessUrlRewriteSavingObserver.php




          <?php
          /**
          * Copyright © 2013-2017 Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          namespace MagentoCatalogUrlRewriteObserver;

          use MagentoCatalogModelCategory;
          use MagentoCatalogUrlRewriteModelCategoryUrlRewriteGenerator;
          use MagentoUrlRewriteModelUrlPersistInterface;
          use MagentoFrameworkEventObserverInterface;

          class CategoryProcessUrlRewriteSavingObserver implements ObserverInterface

          /** @var CategoryUrlRewriteGenerator */
          protected $categoryUrlRewriteGenerator;

          /** @var UrlPersistInterface */
          protected $urlPersist;

          /** @var UrlRewriteHandler */
          protected $urlRewriteHandler;

          /**
          * @param CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator
          * @param UrlPersistInterface $urlPersist
          * @param UrlRewriteHandler $urlRewriteHandler
          */
          public function __construct(
          CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator,
          UrlPersistInterface $urlPersist,
          UrlRewriteHandler $urlRewriteHandler
          )
          $this->categoryUrlRewriteGenerator = $categoryUrlRewriteGenerator;
          $this->urlPersist = $urlPersist;
          $this->urlRewriteHandler = $urlPersist;


          /**
          * Generate urls for UrlRewrite and save it in storage
          *
          * @param MagentoFrameworkEventObserver $observer
          * @return void
          */
          public function execute(MagentoFrameworkEventObserver $observer)

          /** @var Category $category */
          /* $category = $observer->getEvent()->getCategory();
          if ($category->getParentId() == Category::TREE_ROOT_ID)
          return;

          if ($category->dataHasChangedFor('url_key')







          share|improve this answer






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "479"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f182664%2fallowed-memory-size-exhausted-on-category-save-magento-2%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The issue is related to the new way of URL rewrites generator in Magento2. In Magento2, URL rewrites are generated (in url_rewrite table) when user save the category. If you have a complex category structure and assign a category as child of multiple parents or using categories across different store_views , it tries to generate the URL for all combinations and hence get out of memory.



            Here are some links I'd recommend you to go through so you might found a solution for your problem.



            https://github.com/magento/magento2/issues/9706



            https://github.com/magento/magento2/issues/10242



            This is not a solution but a workaround.



            I had also face the same issue with after migrating a huge Magento1 site. Here is the hack down there that is not a solution but it can confirm the issue for you. Update the following core file for instance and then try to update the category name.




            M2vendormagentomodule-catalog-url-rewriteObserverCategoryProcessUrlRewriteSavingObserver.php




            <?php
            /**
            * Copyright © 2013-2017 Magento, Inc. All rights reserved.
            * See COPYING.txt for license details.
            */
            namespace MagentoCatalogUrlRewriteObserver;

            use MagentoCatalogModelCategory;
            use MagentoCatalogUrlRewriteModelCategoryUrlRewriteGenerator;
            use MagentoUrlRewriteModelUrlPersistInterface;
            use MagentoFrameworkEventObserverInterface;

            class CategoryProcessUrlRewriteSavingObserver implements ObserverInterface

            /** @var CategoryUrlRewriteGenerator */
            protected $categoryUrlRewriteGenerator;

            /** @var UrlPersistInterface */
            protected $urlPersist;

            /** @var UrlRewriteHandler */
            protected $urlRewriteHandler;

            /**
            * @param CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator
            * @param UrlPersistInterface $urlPersist
            * @param UrlRewriteHandler $urlRewriteHandler
            */
            public function __construct(
            CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator,
            UrlPersistInterface $urlPersist,
            UrlRewriteHandler $urlRewriteHandler
            )
            $this->categoryUrlRewriteGenerator = $categoryUrlRewriteGenerator;
            $this->urlPersist = $urlPersist;
            $this->urlRewriteHandler = $urlPersist;


            /**
            * Generate urls for UrlRewrite and save it in storage
            *
            * @param MagentoFrameworkEventObserver $observer
            * @return void
            */
            public function execute(MagentoFrameworkEventObserver $observer)

            /** @var Category $category */
            /* $category = $observer->getEvent()->getCategory();
            if ($category->getParentId() == Category::TREE_ROOT_ID)
            return;

            if ($category->dataHasChangedFor('url_key')







            share|improve this answer



























              0














              The issue is related to the new way of URL rewrites generator in Magento2. In Magento2, URL rewrites are generated (in url_rewrite table) when user save the category. If you have a complex category structure and assign a category as child of multiple parents or using categories across different store_views , it tries to generate the URL for all combinations and hence get out of memory.



              Here are some links I'd recommend you to go through so you might found a solution for your problem.



              https://github.com/magento/magento2/issues/9706



              https://github.com/magento/magento2/issues/10242



              This is not a solution but a workaround.



              I had also face the same issue with after migrating a huge Magento1 site. Here is the hack down there that is not a solution but it can confirm the issue for you. Update the following core file for instance and then try to update the category name.




              M2vendormagentomodule-catalog-url-rewriteObserverCategoryProcessUrlRewriteSavingObserver.php




              <?php
              /**
              * Copyright © 2013-2017 Magento, Inc. All rights reserved.
              * See COPYING.txt for license details.
              */
              namespace MagentoCatalogUrlRewriteObserver;

              use MagentoCatalogModelCategory;
              use MagentoCatalogUrlRewriteModelCategoryUrlRewriteGenerator;
              use MagentoUrlRewriteModelUrlPersistInterface;
              use MagentoFrameworkEventObserverInterface;

              class CategoryProcessUrlRewriteSavingObserver implements ObserverInterface

              /** @var CategoryUrlRewriteGenerator */
              protected $categoryUrlRewriteGenerator;

              /** @var UrlPersistInterface */
              protected $urlPersist;

              /** @var UrlRewriteHandler */
              protected $urlRewriteHandler;

              /**
              * @param CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator
              * @param UrlPersistInterface $urlPersist
              * @param UrlRewriteHandler $urlRewriteHandler
              */
              public function __construct(
              CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator,
              UrlPersistInterface $urlPersist,
              UrlRewriteHandler $urlRewriteHandler
              )
              $this->categoryUrlRewriteGenerator = $categoryUrlRewriteGenerator;
              $this->urlPersist = $urlPersist;
              $this->urlRewriteHandler = $urlPersist;


              /**
              * Generate urls for UrlRewrite and save it in storage
              *
              * @param MagentoFrameworkEventObserver $observer
              * @return void
              */
              public function execute(MagentoFrameworkEventObserver $observer)

              /** @var Category $category */
              /* $category = $observer->getEvent()->getCategory();
              if ($category->getParentId() == Category::TREE_ROOT_ID)
              return;

              if ($category->dataHasChangedFor('url_key')







              share|improve this answer

























                0












                0








                0







                The issue is related to the new way of URL rewrites generator in Magento2. In Magento2, URL rewrites are generated (in url_rewrite table) when user save the category. If you have a complex category structure and assign a category as child of multiple parents or using categories across different store_views , it tries to generate the URL for all combinations and hence get out of memory.



                Here are some links I'd recommend you to go through so you might found a solution for your problem.



                https://github.com/magento/magento2/issues/9706



                https://github.com/magento/magento2/issues/10242



                This is not a solution but a workaround.



                I had also face the same issue with after migrating a huge Magento1 site. Here is the hack down there that is not a solution but it can confirm the issue for you. Update the following core file for instance and then try to update the category name.




                M2vendormagentomodule-catalog-url-rewriteObserverCategoryProcessUrlRewriteSavingObserver.php




                <?php
                /**
                * Copyright © 2013-2017 Magento, Inc. All rights reserved.
                * See COPYING.txt for license details.
                */
                namespace MagentoCatalogUrlRewriteObserver;

                use MagentoCatalogModelCategory;
                use MagentoCatalogUrlRewriteModelCategoryUrlRewriteGenerator;
                use MagentoUrlRewriteModelUrlPersistInterface;
                use MagentoFrameworkEventObserverInterface;

                class CategoryProcessUrlRewriteSavingObserver implements ObserverInterface

                /** @var CategoryUrlRewriteGenerator */
                protected $categoryUrlRewriteGenerator;

                /** @var UrlPersistInterface */
                protected $urlPersist;

                /** @var UrlRewriteHandler */
                protected $urlRewriteHandler;

                /**
                * @param CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator
                * @param UrlPersistInterface $urlPersist
                * @param UrlRewriteHandler $urlRewriteHandler
                */
                public function __construct(
                CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator,
                UrlPersistInterface $urlPersist,
                UrlRewriteHandler $urlRewriteHandler
                )
                $this->categoryUrlRewriteGenerator = $categoryUrlRewriteGenerator;
                $this->urlPersist = $urlPersist;
                $this->urlRewriteHandler = $urlPersist;


                /**
                * Generate urls for UrlRewrite and save it in storage
                *
                * @param MagentoFrameworkEventObserver $observer
                * @return void
                */
                public function execute(MagentoFrameworkEventObserver $observer)

                /** @var Category $category */
                /* $category = $observer->getEvent()->getCategory();
                if ($category->getParentId() == Category::TREE_ROOT_ID)
                return;

                if ($category->dataHasChangedFor('url_key')







                share|improve this answer













                The issue is related to the new way of URL rewrites generator in Magento2. In Magento2, URL rewrites are generated (in url_rewrite table) when user save the category. If you have a complex category structure and assign a category as child of multiple parents or using categories across different store_views , it tries to generate the URL for all combinations and hence get out of memory.



                Here are some links I'd recommend you to go through so you might found a solution for your problem.



                https://github.com/magento/magento2/issues/9706



                https://github.com/magento/magento2/issues/10242



                This is not a solution but a workaround.



                I had also face the same issue with after migrating a huge Magento1 site. Here is the hack down there that is not a solution but it can confirm the issue for you. Update the following core file for instance and then try to update the category name.




                M2vendormagentomodule-catalog-url-rewriteObserverCategoryProcessUrlRewriteSavingObserver.php




                <?php
                /**
                * Copyright © 2013-2017 Magento, Inc. All rights reserved.
                * See COPYING.txt for license details.
                */
                namespace MagentoCatalogUrlRewriteObserver;

                use MagentoCatalogModelCategory;
                use MagentoCatalogUrlRewriteModelCategoryUrlRewriteGenerator;
                use MagentoUrlRewriteModelUrlPersistInterface;
                use MagentoFrameworkEventObserverInterface;

                class CategoryProcessUrlRewriteSavingObserver implements ObserverInterface

                /** @var CategoryUrlRewriteGenerator */
                protected $categoryUrlRewriteGenerator;

                /** @var UrlPersistInterface */
                protected $urlPersist;

                /** @var UrlRewriteHandler */
                protected $urlRewriteHandler;

                /**
                * @param CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator
                * @param UrlPersistInterface $urlPersist
                * @param UrlRewriteHandler $urlRewriteHandler
                */
                public function __construct(
                CategoryUrlRewriteGenerator $categoryUrlRewriteGenerator,
                UrlPersistInterface $urlPersist,
                UrlRewriteHandler $urlRewriteHandler
                )
                $this->categoryUrlRewriteGenerator = $categoryUrlRewriteGenerator;
                $this->urlPersist = $urlPersist;
                $this->urlRewriteHandler = $urlPersist;


                /**
                * Generate urls for UrlRewrite and save it in storage
                *
                * @param MagentoFrameworkEventObserver $observer
                * @return void
                */
                public function execute(MagentoFrameworkEventObserver $observer)

                /** @var Category $category */
                /* $category = $observer->getEvent()->getCategory();
                if ($category->getParentId() == Category::TREE_ROOT_ID)
                return;

                if ($category->dataHasChangedFor('url_key')








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 19 '17 at 10:47









                saiidsaiid

                6582822




                6582822



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f182664%2fallowed-memory-size-exhausted-on-category-save-magento-2%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Nidaros erkebispedøme

                    Birsay

                    Was Woodrow Wilson really a Liberal?Was World War I a war of liberals against authoritarians?Founding Fathers...