magento-1.9

Memory limit has been reached - magento 1.9


After migrating my magneto site to new server (CentOS 6 ) i can't update or upload new images to any of my products. its showing Memory limit has been reached while uploading any images.

logs :

2016-02-04T07:24:35+00:00 ERR (3): Notice: Undefined index: httponly in /var/www/vhosts/domain.com/httpdocs/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 96
2016-02-04T07:24:35+00:00 ERR (3): Notice: Undefined index: httponly in /var/www/vhosts/domain.com/httpdocs/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 96
2016-02-04T07:24:35+00:00 ERR (3): Notice: Undefined index: secure in /var/www/vhosts/domain.com/httpdocs/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 98
2016-02-04T07:24:35+00:00 ERR (3): Notice: Undefined index: domain in /var/www/vhosts/domain.com/httpdocs/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 100

enter image description here


Solution

  • For memory limit issue while uploading the product image, go to lib/Varien/Image/Adapter open Gd2.php

    Now search for method protected function _convertToByte($memoryValue) i.e

    protected function _convertToByte($memoryValue)
    {
        if (stripos($memoryValue, 'M') !== false) {
            return (int)$memoryValue * 1024 * 1024;
        }
        elseif (stripos($memoryValue, 'KB') !== false) {
            return (int)$memoryValue * 1024;
        }
    
       return (int)$memoryValue;
    }
    

    Make the following changes in the above method like :

    protected function _convertToByte($memoryValue)
    {
         /*
         if (stripos($memoryValue, 'M') !== false) {
             return (int)$memoryValue * 1024 * 1024;
         }
         elseif (stripos($memoryValue, 'KB') !== false) {
             return (int)$memoryValue * 1024;
         }
    
         return (int)$memoryValue;
         */
         return 2147483648;
         //1024*1024*1024*2 = 2G
    }