[maemo-commits] [maemo-commits] r18330 - in projects/haf/trunk/hildon-thumbnail: . daemon
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue May 12 14:18:24 EEST 2009
- Previous message: [maemo-commits] r18329 - in projects/haf/trunk/ke-recv: debian src
- Next message: [maemo-commits] r18332 - projects/haf/trunk/hildon-thumbnail/daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2009-05-12 14:18:18 +0300 (Tue, 12 May 2009) New Revision: 18330 Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c Log: 2009-05-12 Leonid Moiseichuk <leonid.moiseichuk at nokia.com> * daemon/hildon-thumbnail-daemon.c: 1. config.h and HAVE_OSSO was not known = memory checks was never used 2. oom functions has sense to have conditionally compiled 3. thumbnailer_oom is just for debugging purposes when users complains 4. memory tracking are expensive functions, so they shall be enabled as late as possible. But before initialization has sense to check memory conditions and exit if they are bad 5. oom_adj nice to have set to 16 to notify kernel that this process can be killed if used memory grows too much 6. limit will be counted as 1/8 of current memory, 64 bytes is too stong for check, I suggest to use 1024 and reduce if we will get problems. 64 was set due to broken .gif files Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog =================================================================== --- projects/haf/trunk/hildon-thumbnail/ChangeLog 2009-05-12 11:17:41 UTC (rev 18329) +++ projects/haf/trunk/hildon-thumbnail/ChangeLog 2009-05-12 11:18:18 UTC (rev 18330) @@ -1,3 +1,19 @@ +2009-05-12 Leonid Moiseichuk <leonid.moiseichuk at nokia.com> + + * daemon/hildon-thumbnail-daemon.c: + + 1. config.h and HAVE_OSSO was not known = memory checks was never used + 2. oom functions has sense to have conditionally compiled + 3. thumbnailer_oom is just for debugging purposes when users complains + 4. memory tracking are expensive functions, so they shall be enabled + as late as possible. But before initialization has sense to check memory + conditions and exit if they are bad + 5. oom_adj nice to have set to 16 to notify kernel that this process + can be killed if used memory grows too much + 6. limit will be counted as 1/8 of current memory, 64 bytes is too + stong for check, I suggest to use 1024 and reduce if we will get problems. 64 + was set due to broken .gif files + 2009-05-12 Philip Van Hoof <pvanhoof at codeminded.be> * thumbs/hildon-thumbnail-obj.c: Memleak fix, Bugfix for Bug #116170 Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c 2009-05-12 11:17:41 UTC (rev 18329) +++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-daemon.c 2009-05-12 11:18:18 UTC (rev 18330) @@ -23,6 +23,7 @@ * */ +#include "config.h" #include <linux/sched.h> #include <sched.h> @@ -39,6 +40,10 @@ #include <malloc.h> #endif +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdlib.h> #include <unistd.h> #include <glib.h> @@ -369,13 +374,34 @@ g_free (path); } +#ifdef HAVE_OSSO static void thumbnailer_oom_func (size_t cur, size_t max, void *data) { exit(1); } + static void +thumbnailer_oom(void) +{ + osso_mem_usage_t usage; + + osso_mem_get_usage(&usage); + g_critical ("system has not enough memory to handle thumbnails: %u KBytes available", usage.free >> 10); + thumbnailer_oom_func(0, 0, NULL); +} + +static void set_oom_adj(void) +{ + int fd = open("/proc/self/oom_adj", O_WRONLY); + write(fd, "16", 2); + close(fd); +} + +#endif + +static void create_dummy_files (void) { gchar *dir; @@ -395,14 +421,16 @@ { DBusGConnection *connection; GError *error = NULL; - int result; #if defined (HAVE_MALLOPT) && defined(M_MMAP_THRESHOLD) mallopt (M_MMAP_THRESHOLD, 128 *1024); #endif #ifdef HAVE_OSSO - result = osso_mem_saw_enable(4 << 20, 64, thumbnailer_oom_func, NULL); + if ( osso_mem_in_lowmem_state() ) { + thumbnailer_oom(); + } + set_oom_adj(); #endif g_type_init (); @@ -460,7 +488,17 @@ shut_down_after_timeout, main_loop); +#ifdef HAVE_OSSO + if (0 == osso_mem_saw_enable(osso_mem_get_lowmem_limit() >> 3, 1024, thumbnailer_oom_func, NULL) ) { + g_main_loop_run (main_loop); + osso_mem_saw_disable(); + } + else { + thumbnailer_oom(); + } +#else g_main_loop_run (main_loop); +#endif thumb_hal_shutdown (); @@ -488,9 +526,5 @@ g_main_loop_unref (main_loop); } -#ifdef HAVE_OSSO - osso_mem_saw_disable(); -#endif - return 0; }
- Previous message: [maemo-commits] r18329 - in projects/haf/trunk/ke-recv: debian src
- Next message: [maemo-commits] r18332 - projects/haf/trunk/hildon-thumbnail/daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]