Link to home
Start Free TrialLog in
Avatar of rares_dumitrescu
rares_dumitrescu

asked on

Fatal error: Out of memory

I have a problem, i am using a php script file to generate something and put in my mysql db, the problem is that the info is very much and i get something likt this :

Fatal error: Out of memory (allocated 503054336) at /usr/ports/lang/php5/work/php-5.2.3/Zend/zend_hash.c:610 (tried to allocate 1048576 bytes) in /usr/home/gtoplive/public_html/php/inc/__mysql.php on line 375


How can i compress or do something to reduce the memory allocation ?
Avatar of itsbth
itsbth
Flag of Norway image

#1 Use unset() on all the variables you no longer need.
#2 Use  ini_set('memory_limit', '-1'); to disable the memory limit.
#3 Write to a file rather than store it in a variable.
Avatar of etully
etully

I would need a little more specific information about what you're trying to do but in general, the approach is going to probably be to break up the job and do one piece at a time.  For example, if you are reading 1000 records into memory, altering the values, and writing them back to the database, then instead of reading all 1000 into an array you would instead read one record, alter it, and write it back to the database - and then loop to do that 1000 times.

Can you give me a little more detail about how the logic of your script works and what kind of data you're reading into PHP?
Avatar of rares_dumitrescu

ASKER

The scripts works like this...

I get from db about 250 000 records, and then i  combine the information from it in a array, afther that i read the array and insert into another table...
ASKER CERTIFIED SOLUTION
Avatar of etully
etully

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial