From 1bc85a38d543589e6094ed27cf410f69540b35c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 26 Sep 2013 21:19:11 +0200 Subject: [PATCH] libroot: spawn_thread() now creates a detached pthread. * __pthread_destroy_thread() will in turn free the pthread_thread object. * this fixes a leak of 2072 bytes on each thread construction/destruction and #9945. MediaExtractor spawns a thread on construction, which leaked its pthread_thread object on destuction. --- src/system/libroot/os/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/libroot/os/thread.c b/src/system/libroot/os/thread.c index 41721453d3..0f14f29d9d 100644 --- a/src/system/libroot/os/thread.c +++ b/src/system/libroot/os/thread.c @@ -110,6 +110,7 @@ spawn_thread(thread_func entry, const char *name, int32 priority, void *data) __pthread_init_creation_attributes(NULL, thread, &thread_entry, entry, thread, name, &attributes); + thread->flags |= THREAD_DETACHED; attributes.priority = priority; @@ -256,4 +257,3 @@ snooze_until(bigtime_t timeout, int timeBase) { return _kern_snooze_etc(timeout, timeBase, B_ABSOLUTE_TIMEOUT, NULL); } -