Subject: Re: memory leak in _libssh2_channel_open

Re: memory leak in _libssh2_channel_open

From: Daniel Stenberg <>
Date: Fri, 24 Feb 2012 23:04:38 +0100 (CET)

On Thu, 23 Feb 2012, Steven Dake wrote:

> If I run my application for 8 hours, the leak adds up to 300k of memory
> consumed. I had a look into the code for several hours and don't see an
> immediate way to fix the problem. I'm not sure even what the problem is, as
> the channel should free all packets on libssh2_channel_free.

I'm curious if the leak remains if your app exits? I mean, could it be packets
that are received and are just appended in the incoming package queue and then
are never discarded from there?

300K during 8 hours seems like a fairly small amount of memory per packet
(assuming you have traffic semi-often on the connection) which would imply
that the leak doesn't actually occur that often.

Let me point out that the ->payload allocated pointed is normally passed in
to _libssh2_packet_add() where the packet is added to the incoming queue and
it is subsequently freed when that packet has been handled.

Received on 2012-02-24