php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38718 COM property(IDispatch) cause Memory Leaks
Submitted: 2006-09-05 03:36 UTC Modified: 2006-09-13 01:00 UTC
From: xufuyu at gmail dot com Assigned:
Status: No Feedback Package: COM related
PHP Version: 5.1.6 OS: Windows 2000
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xufuyu at gmail dot com
New email:
PHP Version: OS:

 

 [2006-09-05 03:36 UTC] 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.




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-05 08:08 UTC] tony2001@php.net
>$word->Documents->Add(); // memory leaks!!!!!!!!
What does this mean?
How do you detect that?
 [2006-09-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC