X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <48EC02C3.9080403@xs4all.nl> Date: Wed, 08 Oct 2008 02:45:55 +0200 From: Bob van Loosen User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Memory leak with timer References: <48EBDDF4 DOT 20503 AT xs4all DOT nl> <20081007232949 DOT GA13962 AT ednor DOT casa DOT cgf DOT cx> In-Reply-To: <20081007232949.GA13962@ednor.casa.cgf.cx> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Christopher Faylor wrote: > On Wed, Oct 08, 2008 at 12:08:52AM +0200, Bob van Loosen wrote: > >> Hi all, >> >> When using a timer I seem to be getting a memory leak. >> It eats up about 8 kilobyte per second. >> >> Here's some example code: >> >> #include >> #include >> #include >> #include >> #include >> >> void nothing(){} >> void Die(char *error){perror(error); exit(1);} >> >> int main() >> { >> struct itimerspec itimer; >> struct sigevent sigev; >> timer_t timer; >> int interval = 16000; >> itimer.it_interval.tv_sec = interval / 1000000; >> itimer.it_interval.tv_nsec = (interval % 1000000) * 1000; >> itimer.it_value.tv_sec = interval / 1000000; >> itimer.it_value.tv_nsec = (interval % 1000000) * 1000; >> sigev.sigev_notify = SIGEV_THREAD; >> sigev.sigev_notify_attributes = 0; >> sigev.sigev_notify_function = ¬hing; >> if (timer_create (CLOCK_REALTIME, &sigev, &timer) < 0) >> Die("timer_create"); >> >> if (timer_settime(timer, 0, &itimer, NULL) < 0) >> Die("timer_settime"); while(1) sleep(1); >> } >> > > This should be fixed in the next snapshot. If you are looking for a > workaround, specifically set the sigev_notify_attributes to > PTHREAD_CREATE_DETACHED. > > > Thanks, that fixed it. Shouldn't PTHREAD_CREATE_DETACHED be default? That's what the opengroup.org site says. Bob. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/