qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCHv2] page_cache: fix memory leak


From: Peter Lieven
Subject: [Qemu-devel] [PATCHv2] page_cache: fix memory leak
Date: Mon, 25 Feb 2013 13:44:00 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2

XBZRLE encoded migration introduced a MRU page cache
meachnism. Unfortunately, cached items where never freed in
case of a collision in the page cache on cache_insert().

This lead to out of memory conditions during XBZRLE migration
if the page cache was small and there where a lot of collisions
in the cache.

Signed-off-by: Peter Lieven <address@hidden>
---
 v2:
  - make g_free unconditional.

 page_cache.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/page_cache.c b/page_cache.c
index ba5640b..376f1db 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -152,6 +152,9 @@ void cache_insert(PageCache *cache, uint64_t addr, uint8_t 
*pdata)
     /* actual update of entry */
     it = cache_get_by_addr(cache, addr);

+    /* free old cached data if any */
+    g_free(it->it_data);
+
     if (!it->it_data) {
         cache->num_items++;
     }
--
1.7.9.5



reply via email to

[Prev in Thread] Current Thread [Next in Thread]