Last active
September 6, 2017 13:18
-
-
Save phpdave/b49b64b44197c8a3400b6d82f7f39d26 to your computer and use it in GitHub Desktop.
Apparent Memory leak in External Stored Procedure with INOUT param w/ PHP's IBM DB2 extension 1.9.9 when binding the parameter in PHP7. When the bindparam on the out parameter is done outside of the loop memory doesn't increase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE PROCEDURE MYLIB.TESTSP ( | |
IN "ID" DECIMAL(7, 0) , | |
INOUT CUSTOMERNAME CHAR(40) ) | |
LANGUAGE RPGLE | |
SPECIFIC MYLIB.TESTSP | |
NOT DETERMINISTIC | |
NO SQL | |
CALLED ON NULL INPUT | |
EXTERNAL NAME 'MYLIB/MYTESTRPG' | |
PARAMETER STYLE GENERAL ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db2Connection = db2_connect('MYDB', 'MYUSER', 'MYPASS',array('i5_lib' => 'MYLIB')); | |
$sql = "CALL MYLIB.TESTSP(?,?)"; | |
$stmt = db2_prepare($db2Connection, $sql); | |
for ($i = 0; $i <= 20; $i++) | |
{ | |
if ($stmt) | |
{ | |
$id = 20; | |
$name = ""; | |
db2_bind_param($stmt, 1, "id", DB2_PARAM_IN); | |
db2_bind_param($stmt, 2, "name", DB2_PARAM_OUT); | |
if (db2_execute($stmt)) | |
{ | |
var_dump($name); | |
echo "<br>"; | |
echo "Memory usage: "; | |
var_dump(memory_get_usage());//Memory usage increases 64 Bytes per call, in old DB2 Memory stays constant. | |
echo "<br>"; | |
} | |
} | |
else | |
{ | |
echo "<b>Last SQL Statement Error Message:</b> ".db2_stmt_errormsg()."<br>"; | |
} | |
if($db2Connection===FALSE) | |
{ | |
echo "<b>Last Connection Error Message:</b> ".db2_conn_errormsg()."<br>"; | |
} | |
} | |
exit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if php variable $name is outside of the loop
$name = "";
memory doesn't increase