0

I am working on a memory leak tool, the thing is: this tool should catch memory leaks only from test program, but what actually happens is, i have created a timer using API timer_create (POSIX), and this is somehow causing a leak of 144+56 bytes.

Any idea, as to how to stop it? How can i make sure, that all malloc requests from timer_create are not logged?

I am using the timer thread function method, and not signal. SIGEV_THREAD

RajSanpui
  • 11,556
  • 32
  • 79
  • 146
  • Did you know that there's already `valgrind` to detect memory leaks? – ThiefMaster Apr 06 '11 at 11:38
  • Can it detect memory leak on ARM and mips target? – RajSanpui Apr 06 '11 at 11:40
  • @ThiefMaster: There is perhaps a bigger world, than the desktop, so please don't limit your thinking only to the x86 (the old Desktop) :-) – RajSanpui Apr 06 '11 at 11:45
  • @kingsmaster1: Does the memory leak happen at each timer_create or only the first time? Some runtimes are used to do some dynamic allocations in a "lazy" way. In your case, the "timer" subsystem may allocate something at the first access, and it's intepreted as a "leak" by the checker. Bye! – Giuseppe Guerrini Apr 06 '11 at 12:28
  • @kingsmaster1: `valgrind` supports ARM, but not mips (http://valgrind.org/docs/manual/dist.news.html). There's a lot of MIPs tools suggested in this question: http://stackoverflow.com/questions/1906228/how-to-profile-memory-usage-of-a-c-program – Adrian Cox Apr 06 '11 at 13:34
  • @Adrian: That won't serve our purpose, we use our own proprietory tools. – RajSanpui Apr 07 '11 at 12:17

1 Answers1

1

I don't see any N in your reported memory leakage, just what appears to be a small constant, so my initial guess is that this is purely one-time overhead of setting up the timer thread system and not an actual memory leak. Try running your program with strace and make sure the timer is destroyed. If so, whatever internal memory is left is a matter of the implementation's quality and not a potential error in your program.

By the way, another good test approach: create 10 or 100 timers, then destroy them all, and compare the amount of memory "leaked". If it's the same as with one, I would say there's no issue.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711