-2

As the title suggests, I am receiving an error when loading my website, Minecraft-Seeds.net It runs using the AV Arcade script, and has been running fine without any hitches for the past year and a half. Recently, the website has been giving me the memory error, and we have made absolutely no changes to the code and even restored previous backups of the website. Our visits have not gone up crazily to explain an increase in resource usage, as we have had a low month this month with around 300,000 visits.

The popular suggestion here Allowed memory size of 33554432 bytes exhausted (tried to allocate 43148176 bytes) in php does not work, as my script has an actual issue which is causing it to use much more memory than I have.

I have looked through the code and am not sure as to where exactly I should begin looking. The mySQL queries appear to have LIMITs on them, so I'm not sure what is causing the error.

If you go to the website right now, it will give you the following place as the origin of the error:

/home/mineseed/public_html/config.php on line 39

This line of code is as follows$new_plays = 4; And I have tried commenting it out, and it results in the error simply jumping around my site to line after line of code, with no clear solution in sight.

Any help is greatly appreciated.

EDIT I've added the config.php file

<?php
// mySQL information
$server = 'localhost';                   // MySql server
$username = 'user';                      // MySql Username
$password = 'pass';                         // MySql Password
$database = 'database';                  // MySql Database

// The following should not be edited
  $con = mysql_connect("$server","$username","$password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("$database", $con); 

//mysql_query("UPDATE ava_games SET height='300' WHERE height='0'") or die (mysql_error());

//
$sql = mysql_query("SELECT * FROM ava_settings");
$row = mysql_fetch_array($sql);
$site_name = $row['site_name'];
$site_description = $row['site_description'];
$site_keywords = $row['site_keywords'];
$site_url = $row['site_url'];
$seo_on = $row['seo_on'];
$template_url = $row['template_url'];
$max_results = $row['max_results'];
$image_height = $row['image_height'];
$image_width = $row['image_width'];
$adsense = $row['adsense'];
$cat_numbers = $row['cat_numbers'];
$email_on = $row['email_on'];
$add_to_site = $row['add_to_site'];
$plays = $row['plays'];
$language = $row['language'];
$featured = $row['featured_games'];
$play_limit = $row['play_limit'];
$adsense_id = $row['adsense_id'];
$new_plays = 4;

// Convert super globals 
if (phpversion() >= '5.0.0') 
{ 
    $HTTP_POST_VARS = ($_POST); 
    $HTTP_GET_VARS = ($_GET); 
}
?>
Community
  • 1
  • 1
Alex Castro
  • 101
  • 2
  • 11
  • 1
    can you post a little more code? This will definitely not cause this message. – Green Black Dec 01 '12 at 18:24
  • @John I've gone ahead and added the entire config file. – Alex Castro Dec 01 '12 at 18:30
  • The problem is obviously not in the config file. You are creating something that consumes lots of memory somewhere before the config is loaded. You need to change server config to make it work and then perform memory profiling to find what's the issue. It might be corrupted data – naugtur Dec 02 '12 at 18:43

3 Answers3

1
  1. First you need to check you are using recursion in your php script, because some time recursion failed, that's why this error occurs.

  2. If you are using too much array so after using it please unset it so it will release some memory for other execution. ie: unset($array)

  3. please increase memory limit in your php.ini or use php function ini_set('memory_limit','128M'); or use .htaccess file to override memory_limit

mbinette
  • 5,094
  • 3
  • 24
  • 32
Ayaz
  • 376
  • 1
  • 3
  • 14
0

Try unsetting variables that are not needed and vacating memory before line 39. Also, continue to clean the code that follows. Though not preferred, you can also increase the memory allocation in php.ini.

The query can be made efficient by pulling in only those columns that's needed,

   Select column1, column2......

Make sure the columns have indexes to achieve faster results. The query also needs to use 'limit' if you are sure about the number of results that needs to be retrieved.

Teena Thomas
  • 5,139
  • 1
  • 13
  • 17
0

I'm sorry for my english. It's very hard to tell where is the memory leak, without looking in code. Yep i'm agree with all fixes ( increasing the php memory, and limiting rows in queries). Memory can fall somewhere when you are working with arrays, or with big files ( parsing xml ), or something like this. Try to find what part of code increasing memory, use var_dump(), debug_backtrace(), or try to use libraries that logs all variables

jorj
  • 153
  • 1
  • 7
  • Looking in your attached code, i would advise to play arround with $sql = mysql_query("SELECT * FROM ava_settings"); $row = mysql_fetch_array($sql); – jorj Dec 01 '12 at 18:36