On Fri, 18 May 2012, Marta wrote:
> I've tried to run valgrind on my embedded system, but I was not able to
> cross-compile it (unsupported architecture, it said...). I'm thinking of
> replicating my experiments at home on my pc to see what happens (and there I
> can use valgrind). If I discover something, I will say it.
I made your program look the invokation many times and then exit, and after
some retries I got this output from valgrind:
(libssh2 from git, built to use OpenSSL)
==12364==
==12364== HEAP SUMMARY:
==12364== in use at exit: 31,315 bytes in 590 blocks
==12364== total heap usage: 566,970 allocs, 566,380 frees, 69,237,837 bytes
allocated
==12364==
==12364== 336 bytes in 1 blocks are definitely lost in loss record 9 of 18
==12364== at 0x4027308: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==12364== by 0x804B99C: libssh2_default_alloc (session.c:67)
==12364== by 0x804FE6E: sftp_open (sftp.c:1172)
==12364== by 0x8050079: libssh2_sftp_open_ex (sftp.c:1222)
==12364== by 0x804A57A: do_sftp (sftp_test.c:219)
==12364== by 0x804A799: main (sftp_test.c:284)
==12364==
==12364== 6,125 (1,540 direct, 4,585 indirect) bytes in 7 blocks are
definitely lost in loss record 17 of 18
==12364== at 0x4027308: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==12364== by 0x804B99C: libssh2_default_alloc (session.c:67)
==12364== by 0x804F157: sftp_init (sftp.c:785)
==12364== by 0x804F5DA: libssh2_sftp_init (sftp.c:924)
==12364== by 0x804A496: do_sftp (sftp_test.c:201)
==12364== by 0x804A799: main (sftp_test.c:284)
==12364==
==12364== 17,138 (12,144 direct, 4,994 indirect) bytes in 22 blocks are
definitely lost in loss record 18 of 18
==12364== at 0x4027308: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==12364== by 0x804B99C: libssh2_default_alloc (session.c:67)
==12364== by 0x805A4AB: _libssh2_channel_open (channel.c:161)
==12364== by 0x804EFC2: sftp_init (sftp.c:737)
==12364== by 0x804F5DA: libssh2_sftp_init (sftp.c:924)
==12364== by 0x804A496: do_sftp (sftp_test.c:201)
==12364== by 0x804A799: main (sftp_test.c:284)
==12364==
==12364== LEAK SUMMARY:
==12364== definitely lost: 14,020 bytes in 30 blocks
==12364== indirectly lost: 9,579 bytes in 60 blocks
==12364== possibly lost: 0 bytes in 0 blocks
==12364== still reachable: 7,716 bytes in 500 blocks
==12364== suppressed: 0 bytes in 0 blocks
==12364== Reachable blocks (those to which a pointer was found) are not shown.
==12364== To see them, rerun with: --leak-check=full --show-reachable=yes
==12364==
==12364== For counts of detected and suppressed errors, rerun with: -v
==12364== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 19 from 6)
Clearly memory leaks. Now the question is why they aren't freed...
-- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-develReceived on 2012-05-18