Still Reachable Leak detected by Valgrind

前端 未结 5 1197
南旧
南旧 2020-11-22 11:42

All the functions mentioned in this block are library functions. How can I rectify this memory leak?

It is listed under the \"Still reachable\" cat

5条回答
  •  無奈伤痛
    2020-11-22 12:47

    Since there is some routine from the the pthread family on the bottom (but I don't know that particular one), my guess would be that you have launched some thread as joinable that has terminated execution.

    The exit state information of that thread is kept available until you call pthread_join. Thus, the memory is kept in a loss record at program termination, but it is still reachable since you could use pthread_join to access it.

    If this analysis is correct, either launch these threads detached, or join them before terminating your program.

    Edit: I ran your sample program (after some obvious corrections) and I don't have errors but the following

    ==18933== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)
    --18933-- 
    --18933-- used_suppression:      2 dl-hack3-cond-1
    --18933-- used_suppression:      2 glibc-2.5.x-on-SUSE-10.2-(PPC)-2a
    

    Since the dl- thing resembles much of what you see I guess that you see a known problem that has a solution in terms of a suppression file for valgrind. Perhaps your system is not up to date, or your distribution doesn't maintain these things. (Mine is ubuntu 10.4, 64bit)

提交回复
热议问题