PHP error Fatal Error. How do we solve the problem?



  • Took the cheapest hotel on unihost.com, poured an online game, all working with the 128-MB of the HEU. Then when the php was treated, the file that was responsible for communicating with the MySQL OBD was mistaken:

    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 43 bytes) in /var/www/user/data/www/site.ru/GameEngine/Database/db_MYSQL.php on line 2986 (Today went to a hotel with 256 MB, did not help;-()

    How do we solve the problem? Should we go to the hotel from 384MB of the HEU?

    This is a function that makes a mistake:

    function mysql_fetch_all($result) {
            $all = array();
            if($result) {
                while($row = mysql_fetch_assoc($result)) { // 2986 строка
                    $all[] = $row;
                }
                return $all;
            }
        }
    


  • It's easy to guess, the web application spends all the memory available on the virtual server. Looking at your code, it becomes clear that a mistake occurs in an attempt to reschedule the request to the OBD table in the operational memory of the server. Clearly, the sample wears a large number of records (the total amount of information in which = 268435456/1024 = 256 MB!). There are several exits: limit the number of requested records from the table( LIMIT, WHERE и т.д ) Or set up a server with a big DHS stock. Preferably the first option, since in the future you'll be safe from such a problem. Anyway, we need to keep an eye on this stuff. ♪

    Here, for example, one row number only scares:

    <b>Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 43 bytes) in /var/www/user/data/www/site.ru/GameEngine/Database/db_MYSQL.php on line 2986</b>
    

    Such gigantic scruples should be broken into a few files, so at least they don't get confused. ♪


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2