ID: 9718
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: COM related
Description: Memory leak when passing String values into methods through COM
On that note, changing code to below also leaks memory.
Variables html_example_test01, etc are declared as public static variables in the COM
component.
Methods set_html_example_test01() etc set the static variables to the string values
passed through the argument.
<? Code block sets all public static variables
$gbl_obj->set_html_example_test01("Test string #01.");
$gbl_obj->set_html_example_test02("Test string #02.");
$gbl_obj->set_html_example_test03("Test string #03.");
$gbl_obj->set_html_example_test04("Test string #04.");
$gbl_obj->set_html_example_test05("Test string #05.");
$gbl_obj->set_html_example_test06("Test string #06.");
$gbl_obj->set_html_example_test07("Test string #07.");
$gbl_obj->set_html_example_test08("Test string #08.");
$gbl_obj->set_html_example_test09("Test string #09.");
$gbl_obj->set_html_example_test10("Test string #10.");
$gbl_obj->set_html_example_test11("Test string #11.");
$gbl_obj->set_html_example_test12("Test string #12.");
$gbl_obj->set_html_example_test13("Test string #13.");
$gbl_obj->set_html_example_test14("Test string #14.");
$gbl_obj->set_html_example_test15("Test string #15.");
$gbl_obj->set_html_example_test16("Test string #16.");
$gbl_obj->set_html_example_test17("Test string #17.");
$gbl_obj->set_html_example_test18("Test string #18.");
$gbl_obj->set_html_example_test19("Test string #19.");
$gbl_obj->set_html_example_test20("Test string #20.");
// script does not leak memory when I remove this code block
?>
I hope this clarifies the problem. Earlier examples weren't right as I have done lots
of code with COM which work without leaking memory.
Previous Comments:
---------------------------------------------------------------------------
[2001-03-14 16:46:18] [EMAIL PROTECTED]
Disregard my previous example with the classes. I've just tried a test without using
classes and it still leaks memory. Consider example below instead, thanks:
Code block sets multiple public variables in COM object.
In below example, $gbl_obj is an instance of the COM object in the global scope of the
PHP page. The public variables are defined as html_example_test01,
html_example_test02, html_example_test03, etc. etc. My code block sets over twenty
public variables in the COM object.
<? Code block sets all public variables in COM object
$gbl_obj->html_example_test01 = "Test string #01.";
$gbl_obj->html_example_test02 = "Test string #02.";
$gbl_obj->html_example_test03 = "Test string #03.";
$gbl_obj->html_example_test04 = "Test string #04.";
$gbl_obj->html_example_test05 = "Test string #05.";
$gbl_obj->html_example_test06 = "Test string #06.";
$gbl_obj->html_example_test07 = "Test string #07.";
$gbl_obj->html_example_test08 = "Test string #08.";
$gbl_obj->html_example_test09 = "Test string #09.";
$gbl_obj->html_example_test10 = "Test string #10.";
$gbl_obj->html_example_test11 = "Test string #11.";
$gbl_obj->html_example_test12 = "Test string #12.";
$gbl_obj->html_example_test13 = "Test string #13.";
$gbl_obj->html_example_test14 = "Test string #14.";
$gbl_obj->html_example_test15 = "Test string #15.";
$gbl_obj->html_example_test16 = "Test string #16.";
$gbl_obj->html_example_test17 = "Test string #17.";
$gbl_obj->html_example_test18 = "Test string #18.";
$gbl_obj->html_example_test19 = "Test string #19.";
$gbl_obj->html_example_test20 = "Test string #20.";
// script does not leak memory when I remove this code block
?>
I am using long variable names like html_example_test01
---------------------------------------------------------------------------
[2001-03-14 09:06:35] [EMAIL PROTECTED]
Corrections to bug report. Ignore previous example, check with the below example
instead.
I'm actually assigning values from inside a child class in PHP and accessing the COM
object in the base class.
eg:
<?php
class Child {
function Child () {
Base::instance();
$this->obj->testvar = "This is a test string.";
}
}
class Base {
function instance() {
$this->obj = new COM("MyObject.MyObject");
}
}
?>
/ Leaks memory when I assign a string to a public variable (testvar) of COM object
(obj) from an instance of Child.
Disregard my previous examples as I've tested my COM object with a simple string
passed as argument to method and it did not leak memory.
I think the above memory leak has something to do with PHP's handling of Object
Oriented Programming...
---------------------------------------------------------------------------
[2001-03-13 23:22:06] [EMAIL PROTECTED]
Bug #9715 is reclassified under this bug.
> Memory leak when passing String value to a static variable in the COM object.
> Memory leak when passing String value as an argument in a method exposed by the COM
>object.
> I use VJ++ to write COM objects, as Java handles its own garbage collection.
Running php 4.0.5-dev ISAPI in IIS 5.0
---------------------------------------------------------------------------
[2001-03-12 22:18:49] [EMAIL PROTECTED]
That wasn't it... I tried it without passing a constant, and it's still leaking
memory! So this is an outstanding serious bug with no workaround.
---------------------------------------------------------------------------
[2001-03-12 21:57:39] [EMAIL PROTECTED]
Found the problem.
It only leaks memory, if I pass a CONSTANT from PHP to the COM object.
All I have to do now is rewrite the php so that I'm passing a variable, not a
constant.
Probably this issue can be closed after someone has a look into it.
---------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view the rest of the
comments, please view the bug report online.
Full Bug description available at: http://bugs.php.net/?id=9718
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]