Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#21 Problem with memory

v1.0_(example)
open
nobody
None
1
2013-03-26
2013-03-26
Matteo Russo
No

Hi all, i'm being crazy with this problem:

echo "
Ram Memory Usage start : ".convert(memory_get_usage(true));
require_once('simple_html_dom.php');

$urls[]="http://www.google.it";
$urls[]="http://www.repubblica.it";
$urls[]="http://www.gazzetta.it";

foreach($urls as $url) {
$dom = file_get_html($url);
echo "
Ram Memory Usage after import : ".convert(memory_get_usage(true));
// do some stuff here
$dom->clear();
echo "
Ram Memory Usage after clear : ".convert(memory_get_usage(true));
}

echo "
Ram Memory Usage end : ".convert(memory_get_usage(true));

?>

this is the output:

Ram Memory Usage start : 512 kb
Ram Memory Usage after import : 1.5 mb
Ram Memory Usage after clear : 1.5 mb
Ram Memory Usage after import : 14.25 mb
Ram Memory Usage after clear : 13.75 mb
Ram Memory Usage after import : 23 mb
Ram Memory Usage after clear : 23 mb
Ram Memory Usage end : 23 mb

As you can see, memory doesn't free after the clear() function!

I try unset($dom); too but nothing...

I've great problem with script more complex than this, where i obtain "maximum error exceed"...

Discussion