sigmahokies Posted June 15, 2015 Share Posted June 15, 2015 Hi everyone I get error message from website - "Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 36 bytes) in" what does it mean? Do I have increase of memory in php.ini? Please let me know Thank you, Gary Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/ Share on other sites More sharing options...
Ch0cu3r Posted June 15, 2015 Share Posted June 15, 2015 It means it tried to allocate 36 more bytes of memory but this exceeds the 64MB memory limit. You can increase the memory but if this happens again then this signifies there is a problem with your script consuming to much memory. 64MB should be more than enough for your needs. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1513911 Share on other sites More sharing options...
CroNiX Posted June 15, 2015 Share Posted June 15, 2015 Generally, yes, just increase the memory. However, it's probably more important to find out WHY it's running out. What are you doing when it runs out? Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1513912 Share on other sites More sharing options...
QuickOldCar Posted June 15, 2015 Share Posted June 15, 2015 Exceeded the max memory limit. Can try to increase it or lower the memory usage for your script. php.ini memory_limit = 128M; htaccess php_value memory_limit 128M; top of php script ini_set('memory_limit','128M'); Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1513913 Share on other sites More sharing options...
sigmahokies Posted June 16, 2015 Author Share Posted June 16, 2015 Cronix, I don't know why it ran out of memory, but strange is previous page is work but next page is not work, but yet program is nearly same as previous page. in few weeks ago, i put thread to hope someone will help me to do table vertical cell data that from GET and POST, several people answer in comment, so I tried to fix by learn from those comment, then page went into error showing those quote about memory is not allowed. Previous page, it works fine, then next page, message error just show up. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514059 Share on other sites More sharing options...
ginerjm Posted June 16, 2015 Share Posted June 16, 2015 Wild guess but you have a loop that is doing something for you but you have allowed it to continue on too long without ending and that's is causing the excess memory usage. Check your foreach or while loops to be sure that they will reach an 'end point' at some time and not keep on forever. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514083 Share on other sites More sharing options...
mac_gyver Posted June 16, 2015 Share Posted June 16, 2015 but yet program is nearly same as previous page in programming, a simple typo in a variable name, can cause your program logic to loop forever, because the code is no longer testing the correct variable. if you cannot find the problem in your code that is causing this, you will need to post the code that reproduces the problem. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514091 Share on other sites More sharing options...
CroNiX Posted June 16, 2015 Share Posted June 16, 2015 i put thread to hope someone will help me to do table vertical cell data that from GET and POST, several people answer in comment, so I tried to fix by learn from those comment, then page went into error showing those quote about memory is not allowed You should post the code that you altered in your above comment then if it was working previous to your modifications Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514120 Share on other sites More sharing options...
sigmahokies Posted June 17, 2015 Author Share Posted June 17, 2015 You want to see my code? there is still see post my code in other thread, called "what is "Fatal error: Unsupported operand types in" mean". Let me know if you can't find this thread, i will post my code in here... Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514191 Share on other sites More sharing options...
JenniferLawrence Posted June 17, 2015 Share Posted June 17, 2015 Typically, this happens in a database call if you don't code it right.Let's say I have the following code WRONG SAMPLE CODE: <?php $id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH); $db = new mysqli('localhost', 'root', 'root', 'root'); $mysqli = $db->prepare("SELECT name FROM test_table WHERE id = ?"); $mysqli->bind_param("i", $id); $mysqli->execute(); $mysqli->bind_result($name); while($mysqli->fetch()) { print_r($name); } ?> It actually will throw you that error because your code looks through your database with the information you are giving it via $_POST, $_GET, .etc. However, since the data it is looking for does not really truly exist in the database, there is no error handling for it so it will just continuously look for the data over and over and therefore the script will actually not stop. That is why you are getting the exhaust error. You have to put your code inside an if statement to make sure that it truly does have that data in your database.Here is the right code. RIGHT SAMPLE CODE: <?php $id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT, FILTER_FLAG_STRIP_HIGH); $db = new mysqli('localhost', 'root', 'root', 'root'); $mysqli = $db->prepare("SELECT name FROM test_table WHERE id = ?"); $mysqli->bind_param("i", $id); $mysqli->execute(); $mysqli->store_result(); if($mysqli->num_rows) { $mysqli->bind_result($name); while($mysqli->fetch()) { print_r($name); } } else { print("Requested data does not exist."); } ?> Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514194 Share on other sites More sharing options...
sigmahokies Posted June 17, 2015 Author Share Posted June 17, 2015 jennifer lawerence I am not using database to make display, I am using GET and POST to display the data. in previous page,I am using database to display because it shows ALL names on display, in next page, I use GET and POST to collect data name that who "show up" for different reasons. For example, there will be meeting in the club, then president request someone to check any member who come in for meeting, then checklist is complete, then click on submit to next page website, then officer can see list of member who showed up at meeting this time, because not all members will show up at meeting. That is what I am trying to create this website. I am still learning PHP. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514198 Share on other sites More sharing options...
JenniferLawrence Posted June 17, 2015 Share Posted June 17, 2015 jennifer lawerence I am not using database to make display, I am using GET and POST to display the data. in previous page,I am using database to display because it shows ALL names on display, in next page, I use GET and POST to collect data name that who "show up" for different reasons. For example, there will be meeting in the club, then president request someone to check any member who come in for meeting, then checklist is complete, then click on submit to next page website, then officer can see list of member who showed up at meeting this time, because not all members will show up at meeting. That is what I am trying to create this website. I am still learning PHP. It is best to show us the code. I'm speculating that you are still pulling data from a database. Otherwise, where is the data being pulled from? A text file? An array of lists in your code? There has to be at least some sort of data type for you to pull from. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514203 Share on other sites More sharing options...
sigmahokies Posted June 17, 2015 Author Share Posted June 17, 2015 Jennifer, All right, there will be two pages code First page code: <!doctype html> <html> <head> <title>Test array with columns</title> </head> <body> <form action="testarray3.php" method="GET"> <fieldset> <?php $column = 5; $Garydb = mysqli_connect(xxxx','xxxx',xxxx') or die("Could not connect to database."); mysqli_select_db($Garydb, 'xxxx'); $sql = "SELECT CONCAT(FirstName,' ',LastName) AS Name FROM Members ORDER BY LastName ASC"; $result = mysqli_query($Garydb, $sql); $num_rows = mysqli_num_rows($result); $rows = ceil($num_rows / $column); while ($row = mysqli_fetch_array($result)) { $data[] = $row['Name']; } echo "<table border='7'>\n"; for($i = 0; $i < $rows; $i++) { echo "<tr>\n"; for($j = 0; $j < $column; $j++) { if(isset($data[$i + ($j * $rows)])) { echo "<td>".$data[$i + ($j * $rows)]."</td><td><input type='checkbox' name='member[]' value='".$data[$i + ($j * $rows)]."'></td>\n"; } } echo "</tr>\n"; } echo "</table>\n"; ?> <input type="submit" value='Attendence'> </fieldset> </form> </body> </html> Second Page (next page) Code: <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table border="1"> <?php $columns = 2; $count = 0; if(isset($_GET['member'])) { $display = ceil($_GET['member']); $rows = ceil($display/$columns); while ($row = array($rows)) { $data['Name'] = $row; } for($i = 0; $i < $rows; $i++) { echo "<tr>"; for($j = 0; $j < $columns; $j++) { if(isset($data[$i + ($j * $row)])) { echo "<td>".$data[$i + ($j * $row)]."</td>"; $count = $count+1; } } echo "</tr>"; } }else{ echo "Fail to get data from previous"; } ?> </table> <table><tr><td><?php echo $count." are attending this meeting tonight." ?></td></tr></table> </body> </html> Second pagesuppose collect data from first page. I'm trying to collect data that been checked on first page, then transfer data to second page. It works with ONE column. But I am trying to create the vertical data instead of row data, vertical data is working on first page, but not work on second page. I think "$data[$i + ($j * $row)]" is not necessary but I'm not sure. I am not professional in PHP yet, but I am learning PHP, I hope I will master PHP in one or two year later. PHP is not easy to understand...Thank you for patient with me. Gary Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514211 Share on other sites More sharing options...
jazzman1 Posted June 18, 2015 Share Posted June 18, 2015 Infinity loop I see here: while ($row = array($rows)) { $data['Name'] = $row; } Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514229 Share on other sites More sharing options...
jazzman1 Posted June 18, 2015 Share Posted June 18, 2015 Try (second page): <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table border="1"> <?php if (!empty($_GET['member'])) { $data = $_GET['member']; foreach (array_chunk($data, 2) as $row): ?> <tr> <?php foreach ($row as $value): ?> <td><?php echo htmlentities($value); ?></td> <?php endforeach; ?> </tr> <?php endforeach; }else { echo "Fail to get data from previous"; } ?> </table> <table><tr><td><?php echo count($_GET['member']) . " are attending this meeting tonight." ?></td></tr></table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514233 Share on other sites More sharing options...
sigmahokies Posted June 18, 2015 Author Share Posted June 18, 2015 Hi Jazzman1 i followed exactly your code, seem it doesn't work...it gets "parse error, syntax error, unexpect 'endforeach' (T_ENDFOREACH) in" on 20 line. it is 18 line in your line in comment above of here. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514250 Share on other sites More sharing options...
CroNiX Posted June 18, 2015 Share Posted June 18, 2015 Did you write the foreach() exactly as he had it? With a : at the end? <?php foreach ($row as $value): ?> Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514251 Share on other sites More sharing options...
sigmahokies Posted June 18, 2015 Author Share Posted June 18, 2015 Cronix, Oops! I changed from ; to : on this line, my habit, heh. Still get error message, it said "Parse error: syntax error, unexpected ':', expecting ',' or ';' in on line 18" Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514252 Share on other sites More sharing options...
sigmahokies Posted June 18, 2015 Author Share Posted June 18, 2015 Oh, I didn't realized there are two : on line 13 and 16, then I changed them to : but still get error in array chunk, it said, Warning: array_chunk() expects parameter 1 to be array, string given in on line 11Warning: Invalid argument supplied for foreach() in on line 11 1 are attending this meeting tonight. 11 line - foreach (array_chunk($data, 2) as $row): (13 line on jazzman1's comment above) Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514253 Share on other sites More sharing options...
jazzman1 Posted June 18, 2015 Share Posted June 18, 2015 Well, I think it's time to see your updated scripts Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514268 Share on other sites More sharing options...
sigmahokies Posted June 22, 2015 Author Share Posted June 22, 2015 Jazzman1, you want to see my update script in php? let me know, I will post my updated script in php in here... Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514587 Share on other sites More sharing options...
sigmahokies Posted June 24, 2015 Author Share Posted June 24, 2015 Jazzman1, Do you want to see my update script? let me know, I will glad to post my updated script in here. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514798 Share on other sites More sharing options...
CroNiX Posted June 24, 2015 Share Posted June 24, 2015 He already asked you to post it on the last post of the last page. Why are you asking him if he wants you to post it? Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514804 Share on other sites More sharing options...
dennis-fedco Posted June 24, 2015 Share Posted June 24, 2015 Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 36 bytes) in" what does it mean? At first I thought it meant "We have 64Mb free, and we tried to allocate 36 bytes in that vast free space, but there was an error", which did not make sense to me. But then I realized it means "We have been allocating memory right and left for the stuff you do in your script and all entire memory limit of 64Mb has been used up and is full. Now when your rampant script tries to allocate 36 more bytes, we just can't take any more". So increase your memory limit, or find a bug in your script that caused this high memory usage. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514820 Share on other sites More sharing options...
ginerjm Posted June 24, 2015 Share Posted June 24, 2015 Which script is giving you the error and on what line number? Determine those things and point us to the code that is doing this thing. Link to comment https://forums.phpfreaks.com/topic/296826-fatal-error-allowed-memory-size-of-67108864-bytes-exhausted-tried-to-allocate-36-bytes-what-does-it-mean/#findComment-1514832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.