PHP 4.0 Bug #9718 Updated: Memory leak when passing String values into methods through COM
| From: | Jason at hspace dot net | Date: | Wed, 14 Mar 2001 21:46:18 +0000 |
| Subject: | PHP 4.0 Bug #9718 Updated: Memory leak when passing String values into methods through COM | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-48949@lists.php.net to get a copy of this message | ||
ID: 9718
User Update by: Jason@hspace.net
Status: Open
Bug Type: COM related
Description: Memory leak when passing String values into methods through COM
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
Previous Comments:
---------------------------------------------------------------------------
[2001-03-14 09:06:35] Jason@hspace.net
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] Jason@hspace.net
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] Jason@hspace.net
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] Jason@hspace.net
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.
---------------------------------------------------------------------------
[2001-03-12 21:48:59] Jason@hspace.net
I added methods to pass String values into the static variables.
Passing String values into method in COM object also leaks memory.
Example:
COM object has method test(String a) and a static variable b
The method sets the variable b to a.
In PHP, I execute the COM object's method:
$t_obj->test("This is a test string.");
Memory leak when passing String into COM object.
---------------------------------------------------------------------------
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