Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

前端 未结 21 1224
猫巷女王i
猫巷女王i 2020-11-21 22:14

This error message is being presented, any suggestions?

Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php

相关标签:
21条回答
  • 2020-11-21 22:43
    ini_set('memory_limit', '-1');
    
    0 讨论(0)
  • 2020-11-21 22:48

    Write

    ini_set('memory_limit', '-1');

    in your index.php at the top after opening of php tag

    0 讨论(0)
  • 2020-11-21 22:50

    Here are two simple methods to increase the limit on shared hosting:

    1. If you have access to your PHP.ini file, change the line in PHP.ini If your line shows 32M try 64M: memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

    2. If you don't have access to PHP.ini try adding this to an .htaccess file: php_value memory_limit 64M

    0 讨论(0)
  • 2020-11-21 22:50

    I was receiving the same error message after switching to a new theme in Wordpress. PHP was running version 5.3 so I switched to 7.2. That fixed the issue.

    0 讨论(0)
  • 2020-11-21 22:50

    Run this command in your Magento root directory php -d memory_limit=4G bin/magento

    0 讨论(0)
  • 2020-11-21 22:51

    I was also having the same problem, looked for phpinfo.ini, php.ini or .htaccess files to no avail. Finally I have looked at some php files, opened them and checked the codes inside for memory. Finally this solution was what I come out with and it worked for me. I was using wordpress, so this solution might only work for wordpress memory size limit problem. My solution, open default-constants.php file in /public_html/wp-includes folder. Open that file with code editor, and find memory settings under wp_initial_constants scope, or just Ctrl+F it to find the word "memory". There you will come over WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT. Just increase it, it was 64 MB in my case, I increased it to 128 MB and then to 200 MB.

    // Define memory limits.
    if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
        if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
            define( 'WP_MEMORY_LIMIT', $current_limit );
        } elseif ( is_multisite() ) {
            define( 'WP_MEMORY_LIMIT', '200M' );
        } else {
            define( 'WP_MEMORY_LIMIT', '128M' );
        }
    }
    
    if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
        if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
            define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
        } elseif ( -1 === $current_limit_int || $current_limit_int > 268435456 /* = 256M */ ) {
            define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
        } else {
            define( 'WP_MAX_MEMORY_LIMIT', '256M' );
        }
    }
    

    Btw, please don't do the following code, because that's bad practice:

    ini_set('memory_limit', '-1');
    
    0 讨论(0)
提交回复
热议问题