Bug #62367 [Com]: OCI8 statement not fully freed if bind data contains references

From: Date: Mon, 03 Aug 2020 19:22:54 +0000
Subject: Bug #62367 [Com]: OCI8 statement not fully freed if bind data contains references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228393@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62367&edit=1

 ID:                 62367
 Comment by:         bluemap dot training at gmail dot com
 Reported by:        galaxy dot mipt at gmail dot com
 Summary:            OCI8 statement not fully freed if bind data contains
                     references
 Status:             Open
 Type:               Bug
 Package:            OCI8 related
 Operating System:   Linux
 PHP Version:        5.4.4
 Block user comment: N
 Private report:     N

 New Comment:

This is very helpful script here. Thanks for providing this.

https://www.bluemap.co/courses/course-detail-cisco-sd-wan.php


Previous Comments:
------------------------------------------------------------------------
[2020-07-21 13:35:37] hrriyasen4 at gmail dot com

I liked your article, Thanks for writing such a wonderful article.
https://www.fusiontechnology.in/php-institute-in-pune.php

------------------------------------------------------------------------
[2020-06-16 09:53:49] arajgure at sevenmentor dot com

Thank you for this wonderful blog . Its really an amazing blog to read. It has lots of information
regarding IoT. Students & working professionals can go through this blog as it would really help
them.

https://www.sevenmentor.com/ccna-course-in-pune-area.php

------------------------------------------------------------------------
[2012-06-19 22:56:30] galaxy dot mipt at gmail dot com

Oh, I swapped actual and expected results by mistake

------------------------------------------------------------------------
[2012-06-19 22:53:45] galaxy dot mipt at gmail dot com

Description:
------------
Probably I miss some point here but anyway - in the test script below bind data is passed to the
query() function as an array from pre-created collection.
On each call memory consumption grows by pretty huge value (~65kB) even though oci_free_statement()
is called.
The important conditions to reproduce:
  1. Bind array contains references. Without those I get
    639500
    639520

  2. PL/SQL script actually writes to one of bound variables. With the second (currently commented
out) version I get
    639516
    657136


Test script:
---------------
function query($data) {
    global $conn;
    $stid = oci_parse($conn, 'begin select :a + :b into :b from dual; end;');
    //$stid = oci_parse($conn, 'declare j number; begin select :a + :b into j from dual;
end;');

    oci_bind_by_name($stid, ':a', $data['a'], 100);
    oci_bind_by_name($stid, ':b', $data['b'], 100);

    oci_execute($stid);
    oci_free_statement($stid);
}

$conn = oci_connect('user', 'pass', 'dbref');
if (!$conn) {
    $e = oci_error();
    die($e['message']);
}

$data = array();
for($i = 0; $i < 1000; $i++) {
    $data[] = array(
        "a"   => 1,
        "b"   => 2
    );
}

print memory_get_usage() . "\n";
for($i = 0; $i < 100; $i++) {
    query(
        array(
            "a" => &$data[$i]["a"],
            "b" => &$data[$i]["b"]
        )
    );
}
print memory_get_usage() . "\n";

oci_close($conn);

Expected result:
----------------
639500
7202720

Actual result:
--------------
639500
639520 or nor far from this


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=62367&edit=1


Thread (11 messages)

« previous php.bugs (#228393) next »