views:

49

answers:

1

This is the code I have:

<?php
$start = memory_get_usage();
$table = new Zend_Db_Table('user');
for ($i = 0; $i < 5; $i++) {
  $row = $table->createRow();
  $row->name = 'Test ' . $i;
  $row->save();
  unset($row);
  echo (memory_get_usage() - $start) . "\n";
}

This is what I see:

90664
93384
96056
98728
101400

Isn't it a memory leak? When I have 500 objects to insert into DB in one script I'm getting memory overflow. Can anyone help?

A: 

If you get a memory error if you insert 500 instead of 5, it really is a leak (could be some caching, too). If memory usage climbs up and down instead, it is normal: the garbage collector is freeing the memory again.

soulmerge
As you see in the example above memory usage doesn't climbs down :( With 500+ objects I have exactly the same dynamic, only going up
Vincenzo
Looks like a leak, then.
soulmerge