-
-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add malloc_count Component to track heap usage #1743
Conversation
It would probably be useful to add an option to disable this if using valgrind, As the API is only available for Host builds it needs to be conditionally compiled (using |
Yes, please. |
The Windows build is failing. That is probably due to the concurrency and the way windows handles files. I saw "Error 5" in the error output which lead me to this post: https://stackoverflow.com/questions/14201870/cmake-fails-to-compile-simple-test-error-5-access-denied. |
I've logged in via RDP to find out what's going on here. There's some mingw startup code which calls |
d08230b
to
dedfeb9
Compare
dedfeb9
to
c97ee62
Compare
c97ee62
to
161114e
Compare
Revised original code to work for Host and Esp8266
161114e
to
f5333e5
Compare
@mikee47 Is this PR ready for merging? |
@slaff Yep, all done thanks. |
Currently,
system_get_free_heap_size()
doesn't return anything meaningful. This PR fixes that using a Component based onmalloc_count
https://panthema.net/2013/malloc_count/.I've also added a couple of functions to enable logging. To use it, add
#include <malloc_count.h>
and callMallocCount::enableLogging()
andMallocCount::setLogThreshold()
as required.The Component also works for the Esp8266 (standard or custom heaps). Enable by adding
COMPONENT_DEPENDS += malloc_count
to the project'scomponent.mk
file.The Component is enabled by default for the Host emulator, but can be disabled using
ENABLE_MALLOC_COUNT=0
.