|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-09-05 08:08 UTC] tony2001@php.net
[2006-09-13 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 21:00:01 2025 UTC |
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.