Backtraces引起的内存泄露
2010-08-10 18:25
417 查看
最近在找服务器的内存泄露,在debug的地方经常发现内存泄露,查看文档以后发现是Backtraces引起的内存泄露
下面是使用Backtraces的方法
务必要对backtrace_symbols的返回值strings调用free
切记
下面是使用Backtraces的方法
#include <execinfo.h> #include <stdio.h> #include <stdlib.h> /* Obtain a backtrace and print it to stdout. */ void print_trace (void) { void *array[10]; size_t size; char **strings; size_t i; size = backtrace (array, 10); strings = backtrace_symbols (array, size); printf ("Obtained %zd stack frames./n", size); for (i = 0; i < size; i++) printf ("%s/n", strings[i]); free (strings); } /* A dummy function to make the backtrace more interesting. */ void dummy_function (void) { print_trace (); } int main (void) { dummy_function (); return 0; }
务必要对backtrace_symbols的返回值strings调用free
切记
相关文章推荐
- 如何避免Handler引起内存泄露
- 【并发】ThreadLocal可能引起的内存泄露
- 如何避免Handler引起内存泄露
- Android中Handler引起的内存泄露
- android学习——Handler引起的内存泄露及解决方法
- 避免Android中Context引起的内存泄露--binbinyang
- Android中引起内存泄露的原因分析
- 使用AndroidStudio分析和解决ImageLoader引起内存泄露问题
- mongodb引起内存泄露问题
- Android中Handler引起的内存泄露
- Android开发内存泄露之--Handler引起的内存泄露
- Android 中Handler可能引起的内存泄露
- Android 中 Handler 引起的内存泄露
- Handler引起的内存泄露
- ThreadLocal可能引起的内存泄露
- 依旧Block调用引起的内存泄露
- Android开发——Handler引起的内存泄露
- Android中Handler引起的内存泄露
- Handler引起的内存泄露
- Handler 引起的内存泄露