Jump to content

Fatal error: Allowed memory size...exhausted??


olimits7

Recommended Posts

Hi,

 

I have an upload script that uploads data to my website, and this upload script has been working fine until recently.

 

In the past I've uploaded 12MB files to my website with no problems, but now when I try to upload the same 12MB file I receive the following error messages:

 

1.  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in ../database.php on line 349

2.  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 103 bytes) in ../vendors.php on line 196

 

I told my hosting company to increase my PHP "memory_limit" from 128M to 256M.

 

I then tried to run the upload script again, but I received the same error. 

 

I'm on a dedicated server, and I currently have a total of 512MB RAM.  I can increase my RAM memory, but it will cost me $20 extra a month; so I want to make sure that increasing the RAM memory will definitely fix this issue first.

 

I don't get it 256M is more than enough for the "memory_limit" and this did work fine in the past and I haven't made any changes to the upload script either.

 

Does anyone have any ideas of what could be causing this memory size issue??

 

Thank you,

 

olimits7

 

 

 

 

Link to comment
Share on other sites

Hi,

 

Besides trying to comment out certain parts of the procedure; is there a way to see which specific part of the code is causing the "memory leak"??

 

Can I search in my server logs??  Or run PHP code to pin point this "memory leak??

 

Thank you,

 

olimits7

Link to comment
Share on other sites

Its telling you

1.  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in ../database.php on line 349

2.  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 103 bytes) in ../vendors.php on line 196

Link to comment
Share on other sites

Hi,

 

Ok, I looked at the code but I'm not that good of a PHP programmer.  Can you take a look at the code below; does everything seem like it's written properly??

 

This part of the code below is what's on "database.php" line 349: $_time = number_format(($_end[1] + $_end[0] - ($_start[1] + $_start[0])), 6);

 

function tep_db_query($query, $link = 'db_link') {

global $$link, $debug;
$query_start = microtime();

if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
  error_log('QUERY ' . $query . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
  }
  $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());

  if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
  $result_error = mysql_error();
  error_log('RESULT ' . $result . ' ' . $result_error . "\n", 3, STORE_PAGE_PARSE_TIME_LOG);
  }

  $_start = explode(' ', $query_start);
  $_end = explode(' ', microtime());
  $_time = number_format(($_end[1] + $_end[0] - ($_start[1] + $_start[0])), 6);
  if ($_time > 0.05)
      error_log($_time.': '.$query."\n\n", 3, 'log.txt');

  $debug['QUERIES'][] = $query;
  $debug['TIME'][] = $_time;
  return $result;
  }

 

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 103 bytes) in ../vendors.php on line 196

 

This part of the code is what's on "vendors.php" line 196: $products_query

 

//Check if product exists
$UPCNumber = str_replace("'", "", $UPCNumber);
$products_query = tep_db_query("SELECT products_id, products_price, products_model FROM ".TABLE_PRODUCTS." WHERE products_model = '".tep_db_input($UPCNumber)."'");
$vendors_query = tep_db_query("SELECT wholesale_price, inventory_levels FROM ".TABLE_VENDORS_TO_PRODUCTS." WHERE products_model = '".tep_db_input($UPCNumber)."' AND vendors_id = '".tep_db_input($VendorID)."'");
$vend = tep_db_fetch_array($vendors_query);

 

Thank you,

 

olimits7

Link to comment
Share on other sites

Yes, the "database.php" is from oscommerce but the "vendors.php" is a custom page.

 

I'm not familiar with debugging code in PHP, but if lines 349 and 196 are causing this error wouldn't these lines be the ones I would have to fix??

 

Or do I have to go through the whole PHP code and comment out parts of the code to see which code that ran already led up to this error to happen on lines 349 and 196??

 

But if I do have to comment out code, I don't know how this will help me.  Because let's say I comment a part of the code that "checks to see if the product is currently in website and if not it adds the product". 

 

If this part of the code is causing the error to happen; I still need to have this code in the script because it is necessary, so what would commenting the code out help me do??  I would have to try rewriting it??

 

Thank you,

 

olimits7

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.