From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws8RN-0001yk-39 for qemu-devel@nongnu.org; Wed, 04 Jun 2014 06:29:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ws8RD-0001y2-UY for qemu-devel@nongnu.org; Wed, 04 Jun 2014 06:29:05 -0400 Message-ID: <538EF4CC.8010703@gmail.com> Date: Wed, 04 Jun 2014 18:28:28 +0800 From: Chen Gang MIME-Version: 1.0 References: <538C6B37.2030400@gmail.com> <8761kh2iok.fsf@blackfin.pond.sub.org> In-Reply-To: <8761kh2iok.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH-trivial] arch_init.c: Free 'cache' in cache_fini() to avoid memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: quintela@redhat.com, QEMU Trivial , Michael Tokarev , dgilbert@redhat.com, QEMU Developers , owasserm@redhat.com, arei.gonglei@huawei.com On 06/04/2014 04:16 PM, Markus Armbruster wrote: > Chen Gang writes: > >> Call g_free() after cache_fini() in migration_end(), but do not call >> g_free() after call cache_fini() in xbzrle_cache_resize() which will >> cause memory leak. >> >> cache_init() and cache_fini() are pair, so need let cache_fini() call >> g_free(cache) to match cache_init(), then fix current issue too. > > I'm not sure I get you. Is the following accurate? > > migration: Plug memory leak in migrate-set-cache-size command > > We call g_free() after cache_fini() in migration_end(), but we don't > call it after cache_fini() in xbzrle_cache_resize(), leaking the > memory. > > cache_init() and cache_fini() are a pair. Since cache_init() > allocates the cache, let cache_fini() free it. This plugs the leak. > Yeah, and excuse me for my poor English. Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed