0

I am just developing my website, but I got an error

"Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes) in...".

The odd thing is that it works fine and my memory usage is about 500,000 right up until a single line in my code:

 echo'<script>alert("'."X-".memory_get_usage(true).'");</script>';
 $queryX = "SELECT `data`,`image`,`date` FROM messages WHERE toX = ? or fromX = ?";
 echo'<script>alert("'."X2-".memory_get_usage(true).'");</script>';
 $stmtX = $connection->prepare($queryX);
 echo'<script>alert("'."X3-".memory_get_usage(true).'");</script>';
 $stmtX->bind_param('ss',$idlistX[$i],$idlistX[$i]);
 echo'<script>alert("'."X4-".memory_get_usage(true).'");</script>';
 $stmtX->bind_result($dataT,$imageT,$dateT);

I have those alerts in to track it. Does anyone know how that last line is causing trouble?

0

1 Answer 1

2

Do you happen to have a blob column?

4294967296 shows that you're trying to allocated memory, coincidently or not, that's the max length of a blob column.

It may as well but a bug, and not a leak, and it could come from the bind statements.

If you do have a blob column, try casting it to varchar in your select statement.

9
  • Yes, The image one is a blob, but empty for now. How do I fix that then? Commented Jul 29, 2016 at 14:04
  • 1
    Firstly, don't store images in the database as blobs. Store the path TO the image in the database and store the image itself on the harddrive. That should fix your problem.
    – Andrei
    Commented Jul 29, 2016 at 14:06
  • I know, but these are images users send to each other so I want them private Commented Jul 29, 2016 at 14:15
  • Storing them in the database or storing them on the harddrive won't make much difference regarding privacy. Arguably you could say that they're more secure on the harddrive, since we're assuming here that one could easier get access to the database than the OS. And since he's got access to the OS, some images will be the least of your worries.
    – Andrei
    Commented Jul 29, 2016 at 14:19
  • Wait, (Thanks for the help btw) I dont understand, how would a user who is not meant to have direct access to the db , be able to access it here (I want a scure db)? And how would I change the blob to prevent this error anyway? Commented Jul 29, 2016 at 14:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.