Wednesday, March 11, 2009

g_thread_init

This afternoon I spent almost two hours hunting a memory leak reported by valgrind. It said that there are 2034 bytes definitely lost in g_hash_table_new_full(), but I am pretty sure that g_hash_table_destroy() is invoked with each key been passed to g_free().

The fix turned out to be a slight modification of call sequence to g_thread_init(), from:
  1. create hash table
  2. add hash entry
  3. g_thread_init()
  4. reclaim hash table
to:
  1. g_thread_init()
  2. create hash table
  3. add hash entry
  4. reclaim hash table
then, the error memory leak error just vanished.

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home