[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 06/07: Exited threads retain less memory
From: |
Andy Wingo |
Subject: |
[Guile-commits] 06/07: Exited threads retain less memory |
Date: |
Sun, 8 Jan 2017 14:51:37 +0000 (UTC) |
wingo pushed a commit to branch master
in repository guile.
commit dffe495d0de1466f62a91a6d74cc0f388e0f4f3f
Author: Andy Wingo <address@hidden>
Date: Sun Jan 8 13:44:38 2017 +0100
Exited threads retain less memory
* libguile/threads.c (on_thread_exit): Lessen excess retention.
---
libguile/threads.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/libguile/threads.c b/libguile/threads.c
index 7d91a01..da5b814 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -475,7 +475,9 @@ guilify_self_2 (SCM dynamic_state)
static void
on_thread_exit (void *v)
{
- /* This handler is executed in non-guile mode. */
+ /* This handler is executed in non-guile mode. Note that although
+ libgc isn't guaranteed to see thread-locals, for this thread-local
+ that isn't an issue as we have the all_threads list. */
scm_i_thread *t = (scm_i_thread *) v, **tp;
t->exited = 1;
@@ -506,11 +508,20 @@ on_thread_exit (void *v)
scm_i_pthread_mutex_unlock (&thread_admin_mutex);
- if (t->vp)
- {
- scm_i_vm_free_stack (t->vp);
- t->vp = NULL;
- }
+ /* Although this thread has exited, the thread object might still be
+ alive. Release unused memory. */
+ t->freelists = NULL;
+ t->pointerless_freelists = NULL;
+ t->dynamic_state = NULL;
+ t->dynstack.base = NULL;
+ t->dynstack.top = NULL;
+ t->dynstack.limit = NULL;
+ {
+ struct scm_vm *vp = t->vp;
+ t->vp = NULL;
+ if (vp)
+ scm_i_vm_free_stack (vp);
+ }
#if SCM_USE_PTHREAD_THREADS
GC_unregister_my_thread ();
- [Guile-commits] branch master updated (a0656ad -> b392d81), Andy Wingo, 2017/01/08
- [Guile-commits] 02/07: Remove thread-exited? check in sigaction, Andy Wingo, 2017/01/08
- [Guile-commits] 01/07: Thread prepare-to-wait respects block_asyncs, Andy Wingo, 2017/01/08
- [Guile-commits] 03/07: Remove thread-specific admin mutex, Andy Wingo, 2017/01/08
- [Guile-commits] 04/07: Enable interrupts only when running thread body, Andy Wingo, 2017/01/08
- [Guile-commits] 06/07: Exited threads retain less memory,
Andy Wingo <=
- [Guile-commits] 05/07: Prevent some interrupts of wait-condition-variable, Andy Wingo, 2017/01/08
- [Guile-commits] 07/07: Fix close-port race., Andy Wingo, 2017/01/08