From: Carsten Haitzler (Rasterman) Date: Fri, 22 Apr 2016 03:03:25 +0000 (+0900) Subject: efreetd - reduce memory usage by using stringshare much more X-Git-Tag: upstream/1.20.0~6641 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4d815dc48c660a336670ec3cc67e6becbdcacfc;p=platform%2Fupstream%2Fefl.git efreetd - reduce memory usage by using stringshare much more lots of long paths for monitoring file paths for icons etc. are in memory for efreetd. this reduces that memory by sharing them much more. @optimization --- diff --git a/src/bin/efreet/efreetd_cache.c b/src/bin/efreet/efreetd_cache.c index fefc852..9e8444f 100644 --- a/src/bin/efreet/efreetd_cache.c +++ b/src/bin/efreet/efreetd_cache.c @@ -89,7 +89,7 @@ subdir_cache_dir_free(Subdir_Cache_Dir *cd) static void * subdir_cache_hash_add(void *hash, const char *key, void *data) { - if (!hash) hash = eina_hash_string_superfast_new(EINA_FREE_CB(subdir_cache_dir_free)); + if (!hash) hash = eina_hash_stringshared_new(EINA_FREE_CB(subdir_cache_dir_free)); if (!hash) return NULL; eina_hash_add(hash, key, data); return hash; @@ -140,7 +140,7 @@ subdir_cache_init(void) // if we don't have a hash in the subdir cache - allocate it if (!subdir_cache->dirs) - subdir_cache->dirs = eina_hash_string_superfast_new(EINA_FREE_CB(subdir_cache_dir_free)); + subdir_cache->dirs = eina_hash_stringshared_new(EINA_FREE_CB(subdir_cache_dir_free)); } static void @@ -303,7 +303,7 @@ icon_cache_update_cache_cb(void *data EINA_UNUSED) if ((!icon_flush) && (!icon_exts)) return ECORE_CALLBACK_CANCEL; if (icon_change_monitors) eina_hash_free(icon_change_monitors); - icon_change_monitors = eina_hash_string_superfast_new + icon_change_monitors = eina_hash_stringshared_new (EINA_FREE_CB(ecore_file_monitor_del)); icon_changes_listen(); subdir_cache_save(); @@ -360,7 +360,7 @@ desktop_cache_update_cache_cb(void *data EINA_UNUSED) desktop_queue = EINA_FALSE; if (desktop_change_monitors) eina_hash_free(desktop_change_monitors); - desktop_change_monitors = eina_hash_string_superfast_new + desktop_change_monitors = eina_hash_stringshared_new (EINA_FREE_CB(ecore_file_monitor_del)); desktop_changes_listen(); subdir_cache_save(); @@ -867,9 +867,9 @@ cache_init(void) goto error; } - icon_change_monitors = eina_hash_string_superfast_new + icon_change_monitors = eina_hash_stringshared_new (EINA_FREE_CB(ecore_file_monitor_del)); - desktop_change_monitors = eina_hash_string_superfast_new + desktop_change_monitors = eina_hash_stringshared_new (EINA_FREE_CB(ecore_file_monitor_del)); efreet_cache_update = 0; diff --git a/src/examples/elementary/codegen_example.edj b/src/examples/elementary/codegen_example.edj deleted file mode 100644 index 4f87ec8..0000000 Binary files a/src/examples/elementary/codegen_example.edj and /dev/null differ diff --git a/src/lib/ecore_file/ecore_file_monitor_inotify.c b/src/lib/ecore_file/ecore_file_monitor_inotify.c index f86b58d..374d709 100644 --- a/src/lib/ecore_file/ecore_file_monitor_inotify.c +++ b/src/lib/ecore_file/ecore_file_monitor_inotify.c @@ -107,7 +107,8 @@ ecore_file_monitor_backend_add(const char *path, void *data) { Ecore_File_Monitor *em; - int len; + char *path2; + size_t len; if (_inotify_fd_pid == -1) return NULL; @@ -123,10 +124,10 @@ ecore_file_monitor_backend_add(const char *path, em->func = func; em->data = data; - em->path = strdup(path); - len = strlen(em->path); - if (em->path[len - 1] == '/' && strcmp(em->path, "/")) - em->path[len - 1] = 0; + len = strlen(path); + path2 = alloca(len + 1); + if (path2[len - 1] == '/' && strcmp(path2, "/")) path2[len - 1] = 0; + em->path = eina_stringshare_add(path2); _monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em))); @@ -149,7 +150,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em) fd = ecore_main_fd_handler_fd_get(_fdh); if (ECORE_FILE_MONITOR_INOTIFY(em)->wd) inotify_rm_watch(fd, ECORE_FILE_MONITOR_INOTIFY(em)->wd); - free(em->path); + eina_stringshare_del(em->path); free(em); } diff --git a/src/lib/ecore_file/ecore_file_monitor_poll.c b/src/lib/ecore_file/ecore_file_monitor_poll.c index 088787e..16f8419 100644 --- a/src/lib/ecore_file/ecore_file_monitor_poll.c +++ b/src/lib/ecore_file/ecore_file_monitor_poll.c @@ -68,6 +68,7 @@ ecore_file_monitor_backend_add(const char *path, void *data) { Ecore_File_Monitor *em; + char *path2; size_t len; if (!path) return NULL; @@ -81,14 +82,14 @@ ecore_file_monitor_backend_add(const char *path, else ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN); - em->path = strdup(path); - len = strlen(em->path); - if (em->path[len - 1] == '/' && strcmp(em->path, "/")) - em->path[len - 1] = 0; - em->func = func; em->data = data; + len = strlen(path); + path2 = alloca(len + 1); + if (path2[len - 1] == '/' && strcmp(path2, "/")) path2[len - 1] = 0; + em->path = eina_stringshare_add(path2); + ECORE_FILE_MONITOR_POLL(em)->mtime = ecore_file_mod_time(em->path); _monitors = ECORE_FILE_MONITOR(eina_inlist_append(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em))); @@ -160,7 +161,7 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em) if (_monitors) _monitors = ECORE_FILE_MONITOR(eina_inlist_remove(EINA_INLIST_GET(_monitors), EINA_INLIST_GET(em))); - free(em->path); + eina_stringshare_del(em->path); free(em); if (_timer) diff --git a/src/lib/ecore_file/ecore_file_monitor_win32.c b/src/lib/ecore_file/ecore_file_monitor_win32.c index f6186f6..20f2ad0 100644 --- a/src/lib/ecore_file/ecore_file_monitor_win32.c +++ b/src/lib/ecore_file/ecore_file_monitor_win32.c @@ -243,6 +243,7 @@ ecore_file_monitor_backend_add(const char *path, { Ecore_File_Monitor_Win32 *m; Ecore_File_Monitor *em; + char *path2; size_t len; if (!path || (*path == '\0')) return NULL; @@ -256,22 +257,17 @@ ecore_file_monitor_backend_add(const char *path, em->func = func; em->data = data; - em->path = strdup(path); - if (!em->path) - { - free(em); - return NULL; - } - len = strlen(em->path); - if (em->path[len - 1] == '/' || em->path[len - 1] == '\\') - em->path[len - 1] = '\0'; + len = strlen(path); + path2 = alloca(len + 1); + if (path2[len - 1] == '/' || path2[len - 1] == '\\') path2[len - 1] = 0; + em->path = eina_stringshare_add(path2); m = ECORE_FILE_MONITOR_WIN32(em); m->file = _ecore_file_monitor_win32_data_new(em, 0); if (!m->file) { - free(em->path); + eina_stringshare_del(em->path); free(em); return NULL; } @@ -280,7 +276,7 @@ ecore_file_monitor_backend_add(const char *path, if (!m->dir) { _ecore_file_monitor_win32_data_free(m->file); - free(em->path); + eina_stringshare_del(em->path); free(em); return NULL; } @@ -301,6 +297,6 @@ ecore_file_monitor_backend_del(Ecore_File_Monitor *em) m = ECORE_FILE_MONITOR_WIN32(em); _ecore_file_monitor_win32_data_free(m->dir); _ecore_file_monitor_win32_data_free(m->file); - free(em->path); + eina_stringshare_del(em->path); free(em); } diff --git a/src/lib/ecore_file/ecore_file_private.h b/src/lib/ecore_file/ecore_file_private.h index 82f9767..7c33ec8 100644 --- a/src/lib/ecore_file/ecore_file_private.h +++ b/src/lib/ecore_file/ecore_file_private.h @@ -76,7 +76,7 @@ struct _Ecore_File_Monitor Ecore_File_Event event, const char *path); - char *path; + const char *path; void *data; Ecore_File *files; };