[Spice-devel] [spice-gtk 2/2] Free display_cache in cache_free()

Christophe Fergeau cfergeau at redhat.com
Wed Oct 14 01:01:55 PDT 2015


On Wed, Oct 14, 2015 at 08:26:47AM +0200, Victor Toso wrote:
> Hey,
> 
> On Mon, Oct 12, 2015 at 04:38:22PM +0200, Christophe Fergeau wrote:
> > Otherwise it will be leaked.
> 
> Actually, it was leaking before:

Yes, I noticed this by running valgrind on test-session. I'll add the
trace to the commit log.

Christophe

> 
> <snip>
> valgrind --leak-check=full --show-leak-kinds=definite ./session
> 
> ==27687== 64 bytes in 4 blocks are definitely lost in loss record 250 of
> 435
> ==27687==    at 0x4C28C50: malloc (vg_replace_malloc.c:299)
> ==27687==    by 0xA6AF058: g_malloc (gmem.c:94)
> ==27687==    by 0xA6C5982: g_slice_alloc (gslice.c:1007)
> ==27687==    by 0x40F112: cache_new (spice-channel-cache.h:54)
> ==27687==    by 0x40F112: cache_image_new (spice-channel-cache.h:64)
> ==27687==    by 0x40F112: spice_session_init (spice-session.c:294)
> ==27687==    by 0xA239B4A: g_type_create_instance (gtype.c:1870)
> ==27687==    by 0xA21C31A: g_object_new_internal (gobject.c:1779)
> ==27687==    by 0xA21DB10: g_object_newv (gobject.c:1926)
> ==27687==    by 0xA21E3FB: g_object_new (gobject.c:1619)
> ==27687==    by 0x40FF4D: spice_session_new (spice-session.c:1479)
> ==27687==    by 0x40E678: test_session_uri (session.c:35)
> ==27687==    by 0xA6CE47A: test_case_run (gtestutils.c:2158)
> ==27687==    by 0xA6CE47A: g_test_run_suite_internal (gtestutils.c:2241)
> ==27687==    by 0xA6CE642: g_test_run_suite_internal (gtestutils.c:2253)
> ==27687==
> ==27687== 64 bytes in 4 blocks are definitely lost in loss record 251 of
> 435
> ==27687==    at 0x4C28C50: malloc (vg_replace_malloc.c:299)
> ==27687==    by 0xA6AF058: g_malloc (gmem.c:94)
> ==27687==    by 0xA6C5982: g_slice_alloc (gslice.c:1007)
> ==27687==    by 0x40F112: cache_new (spice-channel-cache.h:54)
> ==27687==    by 0x40F112: cache_image_new (spice-channel-cache.h:64)
> ==27687==    by 0x40F112: spice_session_init (spice-session.c:294)
> ==27687==    by 0xA239B4A: g_type_create_instance (gtype.c:1870)
> ==27687==    by 0xA21C31A: g_object_new_internal (gobject.c:1779)
> ==27687==    by 0xA21DB10: g_object_newv (gobject.c:1926)
> ==27687==    by 0xA21E3FB: g_object_new (gobject.c:1619)
> ==27687==    by 0x40FF4D: spice_session_new (spice-session.c:1479)
> ==27687==    by 0x40E843: test_session_uri (session.c:55)
> ==27687==    by 0xA6CE47A: test_case_run (gtestutils.c:2158)
> ==27687==    by 0xA6CE47A: g_test_run_suite_internal (gtestutils.c:2241)
> ==27687==    by 0xA6CE642: g_test_run_suite_internal (gtestutils.c:2253)
> ==27687==
> ==27687== LEAK SUMMARY:
> ==27687==    definitely lost: 128 bytes in 8 blocks
> ==27687==    indirectly lost: 0 bytes in 0 blocks
> </snip>
> 
> One of those summary in the commit log would be great!
> ack both patches!
>   toso
> 
> > ---
> >  src/spice-channel-cache.h | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/src/spice-channel-cache.h b/src/spice-channel-cache.h
> > index 238ceb7..e609a67 100644
> > --- a/src/spice-channel-cache.h
> > +++ b/src/spice-channel-cache.h
> > @@ -131,6 +131,7 @@ static inline void cache_clear(display_cache *cache)
> >  static inline void cache_free(display_cache *cache)
> >  {
> >      g_hash_table_unref(cache->table);
> > +    g_slice_free(display_cache, cache);
> >  }
> >  
> >  G_END_DECLS
> > -- 
> > 2.5.0
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20151014/5bc803fd/attachment.sig>


More information about the Spice-devel mailing list