Closed boddumanohar closed 7 years ago
Openssl wikipage has solution for this
https://wiki.openssl.org/index.php/Library_Initialization#Cleanup
Thanks! Would you send a PR to fix the head
related leaks?
As for the crypto, I moved the crypto/ssl initialization and cleanup to pe_load_file_ex
and pe_unload
(pe.c) respectively. Running valgrind here doesn't reveal any related leaks, if I'm reading correctly.
I just checked with the lastest revision of our demo file with the latest commit libpe/master (99175e92). Valgrind still shows me the above errors.
I would love to send a PR to fix the head
related leaks. Could you please assign this issue to me.
I believe those leaks aren't related to the SSL cleanup though. At least I don't see any reference that points to it.
Btw, in the last 2 commits I did rename some types from hashes.h. I updated the demo as well - https://gist.github.com/jweyrich/d631cc923ac5da78bfa2b266c889ed29/revisions#diff-f052edcff552b316ac7cd5f09b9c8000
During the week(end) I plan to do some renames related to resources too.
Yeah they all are gone now. :D
So now we have 2 memory leaks in discoveryNodesPeres
and another inpe_imphash
.
I am working on fixing these.
After the pull #19 the Valgrind's Memcheck output for our demo code shows:
==2351==
==2351== HEAP SUMMARY:
==2351== in use at exit: 0 bytes in 0 blocks
==2351== total heap usage: 9,191 allocs, 9,191 frees, 1,885,492 bytes allocated
==2351==
==2351== All heap blocks were freed -- no leaks are possible
==2351==
==2351== For counts of detected and suppressed errors, rerun with: -v
==2351== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
So now, after this, the entire demo code is free from memory leaks.
Awesome! Thank you!! 🥇 👍
Valgrind shows memory leaks at 5 places in file:
The first 4 errror are due to crypto library we are using.
EVP_cleanup();
which we used before exitingcalc_hash
will only clean the used memory partially.And the last one is because, we are not freeing the linked list (where
head
variable is the head of the linked list). Each node is added after each call toimphash_load_imported_functions
function.