posix timer_create() function causing memory leak on linux

后端 未结 5 530
无人共我
无人共我 2021-01-17 06:40

I am using timer_create function for timer functionality in my application. When timeout happens, a new thread gets created. That time my application\'s memory usage is gett

相关标签:
5条回答
  • 2021-01-17 06:59

    Too few info given, but maybe helps:
    Periodic Timer Overrun and Resource Allocation

    0 讨论(0)
  • 2021-01-17 07:08

    I doubt it has anything to do with your timer.

    If you create a new thread, the thread needs space for the stack. As far as I know this memory gets allocated once at thread creation because it has to be contiguous.

    That may sound like a lot of wasted memory, but it is not. First off, you can lower the stack size if you want, second: Only the address-space inside your process gets allocated. Physical memory only gets allocated if you use the stack.

    0 讨论(0)
  • 2021-01-17 07:09

    This question makes no sense without the code.

    timer_create does not make a thread by itself. Your code must be making the thread.

    Your memory leak is almost certainly caused by something wrong in your code. Since we can't see your code we can't help solve the problem.

    0 讨论(0)
  • 2021-01-17 07:17

    Any thread stays "active" until you exit its thread function. Your leak is most probably the thread's stack - that will not go away until you invoke thread_join or some such.

    0 讨论(0)
  • 2021-01-17 07:18

    Valgrind is an invaluable tool for finding memory leaks in a Linux environment

    0 讨论(0)
提交回复
热议问题