I have used Totalview's Memoryscape to do some memory leaks checks and I have "none", well at least none on the HEAP....but it seems tools like MemoryScape only check the heap, not stack leaks...
I have noticed a small leak occurring on AIX and Solaris (any maybe Linux, still checking)....and am trying to hunt it down.
I do use a single (joinable) thread in my application that does all the work...
Please bear with me, C is not my day job ;-) but I have 2 questions:
If I spawn an POSIX thread and it does malloc's etc...are these on the heap or on the threads stack? Would a memory checking (heap) tool typically also find leaks when a thread does not free a malloc?
What tools would you recommend to use to find leaks on the STACK? I have used "libumem" on Solaris but not sure if that is finding what I need..
Can I perhaps use VALGRIND on Linux to check for leaks on my thread's stack?
Thanks for the help ;-)
Lynton
If I spawn an POSIX thread and it does malloc's etc...are these on the heap or on the threads stack? Would a memory checking (heap) tool typically also find leaks when a thread does not free a malloc?
Everything you get via malloc
, no matter where you call it is from the heap. A memory debugger should be able to catch leaks. Valgrind is a good tool to find leaks, it should work well with threads.
You cannot have a "leak" on the stack. The technical term for local variables are "automatic variables" and they are deallocated as soon as the function exits.
But you CAN have a leak if you have a joinable thread, but do not explicitly call pthread_join()
on the thread handle.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.