olimits7 Posted January 28, 2009 Share Posted January 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/ Share on other sites More sharing options...
olimits7 Posted January 28, 2009 Author Share Posted January 28, 2009 Can anybody help me with this issue?? Thank you, olimits7 Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/#findComment-748477 Share on other sites More sharing options...
JonnoTheDev Posted January 28, 2009 Share Posted January 28, 2009 Your script is exhausted at 128mb. Should not need to use this much memory. I would suggest looking at your code. Comment certain parts out of the procedure to ascertain where the memory leak is occuring. Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/#findComment-748652 Share on other sites More sharing options...
olimits7 Posted January 28, 2009 Author Share Posted January 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/#findComment-748936 Share on other sites More sharing options...
JonnoTheDev Posted January 29, 2009 Share Posted January 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/#findComment-749816 Share on other sites More sharing options...
olimits7 Posted January 29, 2009 Author Share Posted January 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/#findComment-749829 Share on other sites More sharing options...
JonnoTheDev Posted January 29, 2009 Share Posted January 29, 2009 Cant really tell without looking at the whole program. You are going to have to go through line by line and test. Is this osCommerce? - The functions look familiar. Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/#findComment-749832 Share on other sites More sharing options...
olimits7 Posted January 29, 2009 Author Share Posted January 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142748-fatal-error-allowed-memory-sizeexhausted/#findComment-749923 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.