堆内存使用Openssl

时间:2011-10-04 18:23:35

标签: c openssl heap valgrind

我在C中使用Openssl库实现了一个简单的HTTPS服务器。单个连接的堆使用量似乎很大。以下是一些可能占用大堆空间的对象:

  • char readbuffer[8192]
  • SSL_CTX
  • SSL

这是正常的吗?有没有一个工具可以找出哪个对象需要多少堆?

HEAP SUMMARY:
==7644==     in use at exit: 78,502 bytes in 2,366 blocks
==7644==   total heap usage: 3,548 allocs, 1,182 frees, 3,139,689 bytes allocated
==7644==
==7644== LEAK SUMMARY:
==7644==    definitely lost: 0 bytes in 0 blocks
==7644==    indirectly lost: 0 bytes in 0 blocks
==7644==      possibly lost: 0 bytes in 0 blocks
==7644==    still reachable: 78,502 bytes in 2,366 blocks
==7644==         suppressed: 0 bytes in 0 blocks

1 个答案:

答案 0 :(得分:0)

尝试确定哪些malloc调用以及何时调用。 Dmalloc可以提供帮助:http://dmalloc.com/

有一次我还使用了一个简单的包装器脚本来手动跟踪内存分配。我认为就是这个: http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15213-s03/src/interposition/mymalloc.c