当我想使用dmalloc-5.5.2检查跨平台上的内存泄漏时。我包括dmalloc.h,用mips 4.3编译它,并将它与./libdmalldm.a链接.应用程序正常工作,内存在结束时耗尽。但是像这样显示日志:
1451616386: 4539: not freed: '0x6af408|s1' (560 bytes) from 'data.c:808'
1451616386: 4539: not freed: '0x6af808|s1' (560 bytes) from 'data.c:808'
1451616386: 4539: not freed: '0x6af408|s1' (560 bytes) from 'data.c:808'
1451616386: 4539: not freed: '0x6af808|s1' (560 bytes) from 'data.c:808'
1451616386: 4539: not freed: '0x6afc08|s1' (560 bytes) from 'data.c:808'
1451616386: 4539: not freed: '0x6b0008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b1008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b2008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b3008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b4008|s5' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b5008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b7008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b8008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6b9008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6ba008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6bb008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6bc008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6be008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6bf008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c0008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c1008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c2008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c3008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c4008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c5008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c6008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c7008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c8008|s5' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6c9008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6ca008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6cb008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6cc008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6cd008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6ce008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6cf008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6d0008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6d1008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6d2008|s1' (2048 bytes) from 'unknown'
1451616386: 4539: not freed: '0x6d3008|s1' (2048 bytes) from 'unknown'我认为未知的地方是记忆泄漏的地方。但是我不知道为什么dmalloc不能记录内存分配的文件和行。我读过关于dmalloc的文件。我发现:
通常,您可以通过str凭着()或另一个例程来分配内存,因此日志文件列出了在str达普例程中分配内存的位置,这无助于找到内存泄漏的真正来源--称为str凭着的例程。如果没有跟踪调用堆栈的机制,库就无法看到调用方的调用者是谁(可以这么说)。
但在dmalloc.h,仍然存在:
dmalloc_strndup(__FILE__, __LINE__, (str), -1, 0)“未知”信息与strdup.So有关吗?我的问题是为什么dmalloc打印“未知”?
发布于 2017-01-06 11:27:42
“未知意味着没有关联文件和行信息的内存。如果您在C文件中不包括dmalloc.h,或者希望跟踪系统功能中可能的内存泄漏,则这是必要的。”
“无法提供返回地址信息的系统则显示”未知“。”
17.html https://stuff.mit.edu/afs/sipb/project/gnucash-test/src/dmalloc-4.8.2/dmalloc.html
发布于 2021-10-26 21:27:14
正如前面提到的,日志中的未知地址意味着在内存分配期间不使用dmalloc实用程序。所以,dmalloc不知道分配程序是什么。
库函数是不能看到分配器的常见原因之一。因为,库函数与malloc、dmalloc一起分配,因此无法捕获它。
所以,是的。strdup还在方法的内部分配内存。这是一个未知地址的例子,因为它在库中进行分配。正如在这种情况下所提到的,您应该使用堆栈分析,例如val差制。
https://stackoverflow.com/questions/41503783
复制相似问题