php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9718 Memory leak when passing String values into methods through COM
Submitted: 2001-03-12 21:48 UTC Modified: 2001-03-21 13:24 UTC
From: Jason at hspace dot net Assigned:
Status: Closed Package: COM related
PHP Version: 4.0 Latest CVS (12/03/2001) OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: Jason at hspace dot net
New email:
PHP Version: OS:

 

 [2001-03-12 21:48 UTC] Jason at hspace dot 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-12 21:57 UTC] Jason at hspace dot 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 22:18 UTC] Jason at hspace dot 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-13 23:22 UTC] Jason at hspace dot 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-14 09:06 UTC] Jason at hspace dot 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-14 16:46 UTC] Jason at hspace dot net
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 16:58 UTC] Jason at hspace dot net
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.
 [2001-03-20 17:44 UTC] phanto@php.net
could you try again with the latest cvs version. i've rewritten a lot.

harald
 [2001-03-20 17:59 UTC] Jason at hspace dot net
I think that you've fixed the problem. Thanks.
 [2001-03-21 13:24 UTC] phanto@php.net
fixed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC