changeset 2238:80779d942b27

Add filedata counting to watch for filedata leaks This basically counts the number of filedata instances in existence at any given point in time. If the number doesn't drop down to where it's supposed to be, there are leaks.
author Omari Stephens <xsdg@xsdg.org>
date Tue, 13 Nov 2012 06:08:21 +0000
parents db10022a79f3
children 7d1fe1247eda
files src/filedata.c
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/filedata.c	Mon Nov 12 18:44:44 2012 +0000
+++ b/src/filedata.c	Tue Nov 13 06:08:21 2012 +0000
@@ -26,6 +26,10 @@
 
 #include <errno.h>
 
+#ifdef DEBUG_FILEDATA
+gint global_file_data_count = 0;
+#endif
+
 static GHashTable *file_data_pool = NULL;
 static GHashTable *file_data_planned_change_hash = NULL;
 
@@ -383,6 +387,10 @@
 		}
 
 	fd = g_new0(FileData, 1);
+#ifdef DEBUG_FILEDATA
+	global_file_data_count++;
+	DEBUG_2("file data count++: %d", global_file_data_count);
+#endif
 
 	fd->size = st->st_size;
 	fd->date = st->st_mtime;
@@ -534,6 +542,11 @@
 	g_assert(fd->ref == 0);
 	g_assert(!fd->locked);
 
+#ifdef DEBUG_FILEDATA
+	global_file_data_count--;
+	DEBUG_2("file data count--: %d", global_file_data_count);
+#endif
+
 	metadata_cache_free(fd);
 	g_hash_table_remove(file_data_pool, fd->original_path);