Possible memory leak with prepared statements?

Background:

I am trying to learn prepared statements and it is throwing an error that I would like to know how to fix.

The data in the Element table is user-supplied, so I also use a prepared statement for that, and good ... practice, of course.

I spent about an hour looking for this site, and most sites recommend changing the memory limit to a higher value. I don't think it would be necessary, as there are very few rows in the table I am selecting ..

Purpose of the request:

The user loads the page and lists the items. From here, they can purchase the specified items with the points they purchase from participation in the program we are launching. This is a request to list items.

Here is the error:

Fatal error: Allowed memory size 201326592 bytes exhausted (tried to allocate 4294967296 bytes) in (Deleted but file is located) on line 80

Line 80:

$Select_stmt2->bind_result($Item_Key, $Item_Image, $Item_Name, $Item_Amount, $Item_Describe);

      

Additional Information:

Also the $ conn variable is pulled from the second configure.php at header time. I will show it minus the server connection information.

//Connect to Database
$conn = new mysqli('localhost', 'Username', 'Password', 'Table Name');

      

Code:

//Item Points
            $Enabled = 'Enabled';

            $Select_Query2 = "SELECT Item_Key, Item_Image, Item_Name, Item_Amount, Item_Describe FROM Item WHERE Item_Status = ?";
            $Select_stmt2 = $conn->prepare($Select_Query2);
            $Select_stmt2->bind_param('s',$Enabled);
            $Select_stmt2->execute();

            $Select_stmt2->bind_result($Item_Key, $Item_Image, $Item_Name, $Item_Amount, $Item_Describe);
            if(!$Select_stmt2)
            {
                echo'Error: Selecting Items';
            }
            else
            {
                /* Code to display the data for line 80 on the website */
            }

      

+3


source to share


1 answer


Do you have a blob column? The number 4294967296 indicates that you are trying to allocate memory for the maximum blob column length. This might be a bug, but not a leak, and the bind statement might be the culprit. If you have a blob column and it keeps giving an error, try giving it a varchar in your select statement.



+1


source







All Articles