Fix memory issues 07/198007/1 accepted/tizen/4.0/unified/20190118.060006 submit/tizen_4.0/20190117.141550
authorKichan Kwon <k_c.kwon@samsung.com>
Mon, 1 Oct 2018 08:38:41 +0000 (17:38 +0900)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 17 Jan 2019 13:51:19 +0000 (14:51 +0100)
Change-Id: I49df0b310f6f1261fcf09cf85846cabfa2a12503
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
src/common/config-parser.c
src/common/dbus.c
src/daemon/main.c
src/memory/memory-killer.c
src/proc-usage/proc-usage-application.c

index 6583ee57b922081ba6d717021d3f25871c8bf234..4a5aa5a0977558a0d340d0a96959e3bf7f8daf6d 100644 (file)
@@ -94,11 +94,12 @@ API void config_parser_foreach(const char *name, const char *group, config_parse
        if (!key_list) {
                _E("Failed to read the group %s (%s). Foreach function will not launched",
                                group, err ? err->message : NULL);
+               g_clear_error(&err);
                return;
        }
 
        for (i = 0; i < len; i++) {
-               value = g_key_file_get_value(config_file, group, key_list[i], &err);
+               value = g_key_file_get_value(config_file, group, key_list[i], NULL);
                if (!value) {
                        _E("Failed to find the value paired with %s. Skip it", key_list[i]);
                        continue;
@@ -133,6 +134,8 @@ API int config_parser_open(const char *name)
 
        if (!g_key_file_load_from_file(config_file, path, G_KEY_FILE_NONE, &err)) {
                _E("Failed to load %s : %s", path, err ? err->message : NULL);
+               g_key_file_free(config_file);
+               g_clear_error(&err);
                return -EIO;
        }
 
index f9171d403e3a56fb87eeba18c93493a7ea260e6f..f708d6ee238f0b4bb12438d186f6c5876b52738a 100644 (file)
@@ -336,6 +336,7 @@ API void dbus_exit(void)
                g_dbus_node_info_unref(method_handle->node_info);
                free(method_handle);
        }
+       g_slist_free(dbus_method_handle_list);
 
        /* Remove D-Bus signal list */
        G_SLIST_FOREACH_WITH_REMOVE(dbus_signal_handle_list, signal_handle) {
@@ -346,6 +347,7 @@ API void dbus_exit(void)
                free(signal_handle->path);
                free(signal_handle);
        }
+       g_slist_free(dbus_signal_handle_list);
 
        g_object_unref(conn);
 }
index cb1080bc320415430f9a48132b3fb690cb86a486..c6a015bbfd9e14bc87b039b47fc50d89e8a9eebc 100644 (file)
@@ -128,6 +128,8 @@ static void base_unload_library(void)
 
        G_SLIST_FOREACH_WITH_REMOVE(library_list, library)
                dlclose(library);
+
+       g_slist_free(library_list);
 }
 
 int main(int argc, char **argv)
index 339db5ed1f1ce46e74a487449ecd510645e57ce0..51034964374e473279c98d26b8f7c6b345df5342 100644 (file)
@@ -157,8 +157,10 @@ static int memory_killer_get_candidates(enum memory_killer_range range, GSList *
                                continue;
                        }
 
-                       if (strncmp(label, "User::Pkg::", 11))
+                       if (strncmp(label, "User::Pkg::", 11)) {
+                               g_free(candidate);
                                continue;
+                       }
                }
 
                ret = procfs_get_pid_basename(pid, NAME_MAX, candidate->basename);
@@ -275,7 +277,7 @@ retain_memory:
                        break;
                }
        }
-       g_slist_free_full(candidates, g_free);
+       g_slist_free(candidates);
        candidates = NULL;
 
        if (range == MEMORY_KILLER_RANGE_ONLY_APP && need_to_retain > 0) {
index 617f15ea1ef4cbadeff6133ffe92a0907115d9ff..ec0288a9a6070f851d4d4d09cd41fbe915a6b37f 100644 (file)
@@ -150,6 +150,7 @@ GVariant *proc_usage_application_get_all_memory_usages(void)
                g_assert(appusage);
                g_variant_builder_add_value(&builder, appusage);
        }
+       g_slist_free(applist);
 
        return g_variant_new("(a(su))", &builder);
 }
@@ -219,6 +220,7 @@ GVariant *proc_usage_application_get_all_cpu_usages(void)
 
                g_variant_builder_add_value(&builder, appusage);
        }
+       g_slist_free(applist);
 
        return g_variant_new("(a(su))", &builder);
 }