The recent fixes to the COM extension (for the 4_3 branch) have helped
with a lot of the memory leaking that was occuring.  Working with
the latest snapshot I've done some additional work to clean up the
few remaining leaks I am seeing in my COM calls.  I believe that the
two patches below eliminate all the overloaded COM memory leaks in
the 4_3 branch.

1) In php_COM_call_function_handler() the constructor block is:

        if (zend_llist_count(property_reference->elements_list)==1
                && !strcmp(Z_STRVAL(function_name->element), "com")) {
                /* constructor */
                PHP_FN(com_load)(INTERNAL_FUNCTION_PARAM_PASSTHRU);
                *object = *return_value;
                pval_copy_constructor(object);
                pval_destructor(&function_name->element);
                return;
        }

After tracing the memory leaks that PHP reports when executing "$xml =
new COM('MSXML.DOMDocument');" I believe that the issue is the
replacing of *object with *return_value.  The original allocated memory
of *object is now lost (and PHP reports it as a leak in the debug
version).  I added a "zval_dtor(object);" just before replacing the
value of *object and the memory leaks are cleared up.

2) At the bottom of do_COM_propput() is this line:

        efree(new_value); // FREE_VARIANT does a VariantClear() which is not
desired here !

Back in September (around the release of 4.2.3) I asked about why this
change was made as it causes the value that is being put to never be
released (as referenced in PHP Weekly Summaries #101 and #103).  If I
revert this to FREE_VARIANT() (along with the first patch) it
eliminates all the memory leaks I am seeing with the overload COM
running under the ISAPI.

I have done initial testing of the COM usage in my PHP code with both
these patches and haven't seen any problems.  I haven't had any luck
getting a response from the authors of the code areas in question.
Is there someone else who can consider these patches (in particular why

the FREE_VARIANT was changed to an efree)?

Michael Sisolak
[EMAIL PROTECTED]

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to