[php-src] Issue #8136: ftp_nlist memory leak

From: Date: Tue, 22 Feb 2022 11:53:17 +0000
Subject: [php-src] Issue #8136: ftp_nlist memory leak
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239962@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8136
Author: pyrsmk

### Description

I have a micro service that is watching a FTP directory every N seconds. I noticed on my VM metrics
that I had a memory leak somewhere. It didn't come from my code since the used memory was
stable, so it probably came from a PHP extension instead. After narrow down the responsible code,
and tested a couple of FTP libraries, I soon realized that it came from ftp_nlist.

Here's a snippet to reproduce the issue, while watching the used memory with watch -n 1
free -m:

```php
<?php

$ftp = ftp_connect('localhost', 2121, 1);
ftp_login($ftp, 'anonymous', 'anonymous');

while (true) {
    ftp_nlist($ftp, '.');
    usleep(1000);
}
```

I tried to close the connection after each call, but the leak was still the same.

### PHP Version

PHP 8.1.1

### Operating System

Alpine Linux inside Docker


Thread (1 message)

  • pyrsmk
« previous php.bugs (#239962) next »