[php-src] Issue #18873: `OCI_RETURN_LOBS` flag causes oci8 to leak memory
| From: | mvorisek | Date: | Wed, 18 Jun 2025 10:37:33 +0000 |
| Subject: | [php-src] Issue #18873: `OCI_RETURN_LOBS` flag causes oci8 to leak memory | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250275@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/18873
Author: mvorisek
### Description
The following code:
https://raw.githubusercontent.com/php/pecl-database-oci8/9a1241341cd02aa68c587046f11b0343bc713b8f/tests/gh-4-return-lob.phpt
(2 lines changed of https://raw.githubusercontent.com/php/pecl-database-oci8/9a1241341cd02aa68c587046f11b0343bc713b8f/tests/gh-4.phpt
already present test)
Resulted in this output:
```
array(9) {
[1]=>
int(6872016)
[2]=>
int(6872368)
[3]=>
int(6872400)
[4]=>
int(6872432)
[5]=>
int(6872464)
...
}
PHP Fatal error: Uncaught Exception: memory leak detected in ...
```
But I expected this output instead:
```
ok
```
Notes:
https://github.com/php/pecl-database-oci8/pull/29
fixed memory leak once after 8th descriptor create, and such fix can be backported into PHP 8.2
however it is not critical and maybe it can be even considered a feature.
This issue is about a clear memory leak after every iteration when the data are fetched using
OCI_RETURN_LOBS flag. Such flag imply the data are not returned as descriptor, but as a
string instead. So it seems the descriptor is somehow not released after the data are read.
### PHP Version
```plain
PHP 8.2 - master
```
### Operating System
any (tested linux and Windows)