[eluser]Unknown[/eluser]
Hi,
I have a problem. When I loop through a bunch of sql selects based on year and month
and I get a hit in a table, the memory usage EXPLODES !!!!
Here is some log output containing memory usage:
INFO - 2011-12-09 16:10:26 --> LOOP : NF: 28 YEAR: 2010 MONTH: '01' mem set: 1788664
INFO - 2011-12-09 16:10:27 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:27 --> LOOP : NF: 28 YEAR: 2010 MONTH: '02' mem set: 1793128
INFO - 2011-12-09 16:10:28 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:28 --> LOOP : NF: 28 YEAR: 2010 MONTH: '03' mem set: 1793728
INFO - 2011-12-09 16:10:30 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:30 --> LOOP : NF: 28 YEAR: 2010 MONTH: '04' mem set: 1794328
INFO - 2011-12-09 16:10:32 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:32 --> LOOP : NF: 28 YEAR: 2010 MONTH: '05' mem set: 1794928
INFO - 2011-12-09 16:10:33 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:33 --> LOOP : NF: 28 YEAR: 2010 MONTH: '06' mem set: 1795528
INFO - 2011-12-09 16:10:35 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:35 --> LOOP : NF: 28 YEAR: 2010 MONTH: '07' mem set: 1796128
INFO - 2011-12-09 16:10:37 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:37 --> LOOP : NF: 28 YEAR: 2010 MONTH: '08' mem set: 1796728
INFO - 2011-12-09 16:10:38 --> RESULT COUNT IS: 0
INFO - 2011-12-09 16:10:38 --> LOOP : NF: 28 YEAR: 2010 MONTH: '09' mem set: 1797392
INFO - 2011-12-09 16:10:45 --> RESULT COUNT IS: 224162
INFO - 2011-12-09 16:10:45 --> LOOP : NF: 28 YEAR: 2010 MONTH: '10' mem set: 486504280
NF = number of fields
So if a row of data in the table is 1000 bytes total (it's actually a lot less)
, and I have 224162 records,
then 224162*1000 = 224 megs of memory. Let's throw in a little bit for overhead .
I should not get DOUBLE the amount of memory used !!!
I am doing this with the results of the query:
foreach($query->result_array() as $row)
What am I doing wrong ?
How can I fix it ?
Best regards,
Phillybob