From 5a8582b041c46a2298662b8671d475324f460175 Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Sun, 8 Jan 2006 08:22:47 +0000 Subject: [PATCH] Resurrect this function. Sun Jan 8 03:22:22 2006 Soeren Sandmann * process.c (process_flush_caches): Resurrect this function. * collector.c (collector_reset): Call it from here --- ChangeLog | 6 ++++++ collector.c | 2 ++ process.c | 40 ++++++++++++++++++++++++++++++++++++++++ process.h | 2 +- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c77d478..757d71f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jan 8 03:22:22 2006 Soeren Sandmann + + * process.c (process_flush_caches): Resurrect this function. + + * collector.c (collector_reset): Call it from here + Sun Jan 8 02:19:34 2006 Soeren Sandmann * TODO: update diff --git a/collector.c b/collector.c index 96e0b3e..5cea279 100644 --- a/collector.c +++ b/collector.c @@ -240,6 +240,8 @@ collector_reset (Collector *collector) { if (collector->stash) stack_stash_free (collector->stash); + + process_flush_caches(); collector->stash = stack_stash_new (); collector->n_samples = 0; diff --git a/process.c b/process.c index f40059c..c230f10 100644 --- a/process.c +++ b/process.c @@ -200,6 +200,44 @@ process_free_maps (Process *process) g_list_free (process->maps); } + +static void +free_process (gpointer key, gpointer value, gpointer data) +{ + char *cmdline = key; + Process *process = value; + +#if 0 + g_print ("freeing: %p\n", process); + memset (process, '\0', sizeof (Process)); +#endif + g_free (process->cmdline); +#if 0 + process->cmdline = "You are using free()'d memory"; +#endif + process_free_maps (process); + g_list_free (process->bad_pages); + g_free (cmdline); + + g_free (process); +} + +void +process_flush_caches (void) +{ + if (!processes_by_cmdline) + return; + + g_hash_table_foreach (processes_by_cmdline, free_process, NULL); + + g_hash_table_destroy (processes_by_cmdline); + g_hash_table_destroy (processes_by_pid); + + processes_by_cmdline = NULL; + processes_by_pid = NULL; +} + + static gboolean process_has_page (Process *process, gulong addr) { @@ -343,6 +381,8 @@ process_get_from_pid (int pid) return p; } + + #include #include #include diff --git a/process.h b/process.h index d4ff4d5..40763ac 100644 --- a/process.h +++ b/process.h @@ -59,6 +59,6 @@ const Symbol *process_lookup_symbol_with_filename (Process *process, const char *filename, gulong address); const char * process_get_cmdline (Process *process); - +void process_flush_caches (void); #endif -- 2.7.4