mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Exited threads retain less memory
* libguile/threads.c (on_thread_exit): Lessen excess retention.
This commit is contained in:
parent
12eb7b8256
commit
dffe495d0d
1 changed files with 17 additions and 6 deletions
|
@ -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 ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue