1

I have a simple HTTPS server implemented with Openssl library in C. The heap usage seems huge for a single connection. The following are some objects that might take big heap space:

  • char readbuffer[8192]
  • SSL_CTX
  • SSL

Is this normal? Is there a tool that can find out which object takes how much heap?

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
trincot
  • 317,000
  • 35
  • 244
  • 286
Wei Shi
  • 4,945
  • 8
  • 49
  • 73

1 Answers1

0

Try figuring out which malloc calls are made and when. Dmalloc can help: http://dmalloc.com/

One time I also used a simple wrapper script to track memory allocations manually. I think it was this one: http://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15213-s03/src/interposition/mymalloc.c

Michel
  • 2,523
  • 2
  • 17
  • 14