#38718 [NEW]: COM property(IDispatch) cause Memory Leaks

From: Date: Tue, 05 Sep 2006 03:36:43 +0000
Subject: #38718 [NEW]: COM property(IDispatch) cause Memory Leaks
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101742@lists.php.net to get a copy of this message
From: xufuyu at gmail dot com Operating system: Windows 2000 PHP version: 5.1.6 PHP Bug Type: COM related Bug description: COM property(IDispatch) cause Memory Leaks 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 bug report at http://bugs.php.net/?id=38718&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38718&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38718&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38718&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38718&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38718&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38718&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38718&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38718&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38718&r=support Expected behavior: http://bugs.php.net/fix.php?id=38718&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38718&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38718&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38718&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38718&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38718&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38718&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38718&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38718&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38718&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38718&r=mysqlcfg

« previous php.bugs (#101742) next »