Subject: Re: sftp functions leaking memory?

Re: sftp functions leaking memory?

From: Alexander Lamaison <swish_at_lammy.co.uk>
Date: Fri, 18 May 2012 18:11:38 +0100

On 18 May 2012 11:34, Marta <marta.m.batlle_at_gmail.com> wrote:
>
> A bit of background: I'm working with an embedded system[1] and I
> needed a library to manage sftp transfers that need to be done
> periodically, so I used libssh2. Everything was going smooth until I
> realized the process was eating memory, around 2 MB a day. That's not
> a big deal on a bigger system, but having only 64 MB of RAM, in my
> case that is a problem.
>
> I reviewed my code, and having not found any error, I tried to make
> some measurements with one of the examples. I modified the non
> blocking sftp example to operate in a loop (see attachment, if you
> want to compile it you will have to change the pmemlog string to match
> your system, and include the right libssh2_config.h). After 433
> iterations, I made a graph of the heap size. The heap growth is almost
> linear, and it does not seem to stabilize. Another interesting thing
> is that the heap does not grow on each iteration.

FWIW I've let your script run most of the afternoon and in that time
memory usage has climbed from 3.0MB to 3.9MB. I guess that could be a
teeny memory leak but its hard to tell where from.

This in on Window 7 compiled with MSVC8 (2005) reading from /dev/zero
over a gigabit LAN connection. It performed 89 million calls to
libssh2_sftp_read of which only 12,519 returned EAGAIN. Presumably
this would be a higher proportion with higher network latency. A test
under other circumstance might reveal higher leakage.

Alex

-- 
Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2012-05-18