From: Yusuke ENDOH Date: 2010-07-16T20:42:06+09:00 Subject: [ruby-core:31310] Re: [Bug #3566] memory leak when spawning+joining Threads in a loop Hi, 2010/7/16 Eric Wong : > Eric Wong wrote: >> Yusuke ENDOH wrote: >> > 2010/7/14 Eric Wong : >> > > The following loop causes Ruby 1.9.2-rc2 memory usage to grow without bounds: >> > > >> > > �loop { Thread.new {}.join } >> > >> > I think the following patch fixes this issue. >> > Even with the patch applied, memory usage seems to grow slowly. >> > But it will stop eventually, as long as I investigated. >> > I guess it is due to conservative GC. >> >> Yes, this helps stabilize memory growth. �I'll let it run for a few >> hours here and report back if I OOM my machine :) > > Still stable (at 118M) after an hour \o/ Thanks! I'll commit the following patch instead of the previous one, because the previous one seems to cause SEGV when running make test. (sorry!) diff --git a/thread_pthread.c b/thread_pthread.c index e974b73..e832b82 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -226,9 +226,7 @@ get_stack(void **addr, size_t *size) # endif CHECK_ERR(pthread_attr_getguardsize(&attr, &guard)); *size -= guard; -# ifndef HAVE_PTHREAD_GETATTR_NP pthread_attr_destroy(&attr); -# endif #elif defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP pthread_t th = pthread_self(); *addr = pthread_get_stackaddr_np(th); -- Yusuke Endoh