From: Gianni Tedesco Subject: Re: [PATCH 0 of 3] libxl: memory leaks Date: Tue, 3 Aug 2010 11:18:20 +0100 Message-ID: <1280830700.18490.82.camel@qabil.uk.xensource.com> References: <1280754703.18490.65.camel@qabil.uk.xensource.com> <4C56C60D.5060702@eu.citrix.com> <1280757928.18490.72.camel@qabil.uk.xensource.com> <4C57CC53.7030107@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4C57CC53.7030107@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Vincent Hanquez Cc: Ian Campbell , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Tue, 2010-08-03 at 08:59 +0100, Vincent Hanquez wrote: > On 02/08/10 15:05, Gianni Tedesco (3P) wrote: > > It's no big secret or mystery - I only mentioned it because I had > > planned to start work on it quite soon :) > > > > Basically it is to implement properly the current pointer tracking code > > in libxl such that allocations via libxl_(sprintf|malloc) and so on are > > automatically free'd when returning out of the library to a caller. > > Objects returned to callers will still be expected to be free()'d... > > What about, what's wrong with the original design ? > the original design being you stuff everything in the context memtrack > and expect all the objects allocated by libxl (internal AND returned to > the caller) to be free by a ctx_free. This provides a strong proven > guarantee that *everything* has been free. I wasn't aware that was the original design. It's certainly not the case right now. AFAICS that scheme would only guarantee everything has been freed if the caller calls ctx_free() at appropriate points. If libxl were used in a daemon, for example, it would not be simple to come up with a scheme that guarantees memory bounds that are independent from uptime. Also, a simpler way to free everything is exit() :)