Description
Description of defect
When running the example code & configuration from Heap Statistics tutorial, the heap stats do not change after a successful malloc()
. My initial thoughts are that the malloc_wrapper()
is not being called, and therefore the heap stats are not being tallied. However the MBED_HEAP_STATS_ENABLED
configuration appears to be set correctly, so I'm unsure as to why this issue is occurring.
Target(s) affected by this defect ?
NRF52_DK
Toolchain(s) (name and version) displaying this defect ?
n/a
What version of Mbed-os are you using (tag or sha) ?
d9819a72d1d2daea0609e921efde49e9ba06c9b7
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
n/a
How is this defect reproduced ?
Using the instructions on the Heap Statistics tutorial, I have copied and pasted main()
and the mbed_app.json
configuration into mbed-os-example-blinky
and tried to run it on a Nordic NRF52832 Dev Kit (PCA10400).
The output of the serial monitor is shown below:
Starting heap stats example
Start; Current heap: 64
Start; Max heap size: 64
Allocating 1000 bytes
Post-Alloc; Current heap: 64
Post-Alloc; Max heap size: 64
Freed 1000 bytes
Post-Free; Current heap: 64
Post-Free; Max heap size: 64
However, there is no change in the 'Post-Alloc' heap size. I would expect to see the following to indicate that the MBED_HEAP_STATS_ENABLED
is enabled and the malloc()
was successful:
Starting heap stats example
Start; Current heap: 64
Start; Max heap size: 64
Allocating 1000 bytes
Post-Alloc; Current heap: 1064
Post-Alloc; Max heap size: 1064
Freed 1000 bytes
Post-Free; Current heap: 64
Post-Free; Max heap size: 1064
Or I would expect to see the following, which should indicate that MBED_HEAP_STATS_ENABLED
is not enabled:
Starting heap stats example
Start; Current heap: 0
Start; Max heap size: 0
Allocating 1000 bytes
Post-Alloc; Current heap: 0
Post-Alloc; Max heap size: 0
Freed 1000 bytes
Post-Free; Current heap: 0
Post-Free; Max heap size: 0
My initial thought was that the MBED_HEAP_STATS_ENABLED
configuration was not being set properly, resulting in the stdlib malloc()
being called instead of the mbed malloc_wrapper()
, which includes the heap stats tracing.
The output from mbed compile --config -tARM -mNRF52_DK
seems to indicate that the configuration setting is set correctly (see image).
I'm currently out of ideas as to why the heap stats doesn't function as expected,
For reference, the image below shows a screenshot of the program, configuration and unexpected output.