| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <48EBDDF4.20503@xs4all.nl> |
| Date: | Wed, 08 Oct 2008 00:08:52 +0200 |
| From: | Bob van Loosen <loosen AT xs4all DOT nl> |
| User-Agent: | Thunderbird 2.0.0.17 (X11/20080925) |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Memory leak with timer |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
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 <stdio.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
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);
}
--
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |