2

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 51 bytes) in C:\xampp\htdocs\project\App\library\PEAR\MDB2\Driver\mysql.php on line 1160

I have a large DB (1.5GB) and I come up with that error when I am trying to search through the DB for information. I have no idea how to resolve that ? Thank you if anyone could be of help. :-)

hakre
  • 193,403
  • 52
  • 435
  • 836
Kingston Town
  • 63
  • 1
  • 9
  • 2
    Show some code of how do you search? – xdazz Mar 19 '12 at 03:04
  • The size of the db shouldn't matter at all, unless you're sucking the entire contents of the DB into PHP and searching in PHP, which begs the question.... why? – Marc B Mar 19 '12 at 03:10
  • @Marc B, you made the correct guess at the current DB I am using :-D. This project is what people want me to learn, I have no idea why they do so. – Kingston Town Mar 19 '12 at 03:13
  • Then you're stuck. Either fix up the search engine so the searching takes place inside the DBMS, which is not subject to PHP's memory limit, or raise the PHP memory limit. You cannot pour 100 liters of water into a 1 liter cup and expect it to NOT overflow. – Marc B Mar 19 '12 at 03:15
  • @xdazz, the project is not small, replicating is infeasible even I post all of them here,Sincerely. MarcB, Thanks for your explanation I understand it now, – Kingston Town Mar 19 '12 at 03:36
  • @Kingston Town: Please accept the answer if it helped you. That will mark the question as solved. Thank you! – hakre Mar 19 '12 at 19:31

1 Answers1

3

Appart from some crazy loops that you could be performing on your code the most straightforward reason you can be getting that error is if you are completely neglecting the usage of the database and trying to load it all up into PHP.

But that would be crazy! :)

If your database of choice is SQL based try something like:

SELECT *
(...)  
LIMIT 20 // to get the first xx results only

As a side note, it's great that you are learning with a large database as the majority of novice errors (like non indexing tables and things alike will be instantly evident).

Frankie
  • 24,627
  • 10
  • 79
  • 121
  • 3
    Thank you, I always get the best answers from TRUE professionals here. :-) – Kingston Town Mar 19 '12 at 03:33
  • Also, I'd like to add, PHP isn't mean for large scale computing (like searching a 1.5GB table), SQL however, is perfect for the job. Do the searching in MySQL, and have the limited result set returned to PHP. – Madara's Ghost Mar 19 '12 at 19:35