ID:               38718
 Updated by:       [EMAIL PROTECTED]
 Reported By:      xufuyu at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         COM related
 Operating System: Windows 2000
 PHP Version:      5.1.6
 New Comment:

>$word->Documents->Add(); // memory leaks!!!!!!!!
What does this mean?
How do you detect that?


Previous Comments:
------------------------------------------------------------------------

[2006-09-05 03:36:43] xufuyu at gmail dot com

Description:
------------
Hi

consider the line 5 [ $word->Documents->Add(); ] of this example. When
COM property is IDispatch, the PHP will cause memory leaks.

1 <?php
2 $word = new COM("word.application");
3 print "Loaded Word, version {$word->Version}\n"; 
4 $word->Visible = 1; 
5 $word->Documents->Add(); // memory leaks!!!!!!!!
6 $word->Selection->TypeText("This is a test..."); 
7 $word->Documents[1]->SaveAs("Useless test.doc"); 
8 $word->Quit(); 
9 ?>


On the next example, you will see the status of memory leaks.

<?php
$word = new COM("word.application");
print "Loaded Word, version {$word->Version}\n"; 
$word->Visible = 1; 
$word->Documents->Add();
sleep(3);

for ($j=0; $j<10; $j++) {
for ($i=0; $i<100; $i++) {
  $s = $word->Selection;
  $s->TypeText("This is a test...");
  sleep(3);
}
$word->Documents[1]->SaveAs("Useless test.doc"); 
$word->Quit(); 
?>


If I move the IDispatch from the loop, It work fine and memory don't
increase in the loop.

<?php
$word = new COM("word.application");
print "Loaded Word, version {$word->Version}\n"; 
$word->Visible = 1; 
$word->Documents->Add();
sleep(3);

$s = $word->Selection; //
for ($j=0; $j<10; $j++) {
for ($i=0; $i<100; $i++) {
  $s->TypeText("This is a test...");
  sleep(3);
}
$word->Documents[1]->SaveAs("Useless test.doc"); 
$word->Quit(); 
?>

When I check the source code, and set flags to each function, I found
the previous two examples difference with two function,
[php_com_wrap_dispatch] & [php_com_object_free_storage]. I guess
[php_com_object_free_storage] don't release memory clearly when the COM
property is IDispatch.

what's wrong!!!


Thanks.





------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38718&edit=1

Reply via email to