Skip to content

Commit

Permalink
stats - Added stats for reserved heap space for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
geky committed Nov 8, 2016
1 parent b6e8f44 commit 14aa57f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions platform/mbed_alloc_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ static mbed_stats_heap_t heap_stats = {0, 0, 0, 0, 0};
void mbed_stats_heap_get(mbed_stats_heap_t *stats)
{
#ifdef MBED_HEAP_STATS_ENABLED
extern uint32_t mbed_heap_size;
heap_stats.reserved_size = mbed_heap_size;

malloc_stats_mutex->lock();
memcpy(stats, &heap_stats, sizeof(mbed_stats_heap_t));
malloc_stats_mutex->unlock();
Expand Down
1 change: 1 addition & 0 deletions platform/mbed_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef struct {
uint32_t current_size; /**< Bytes allocated currently. */
uint32_t max_size; /**< Max bytes allocated at a given time. */
uint32_t total_size; /**< Cumulative sum of bytes ever allocated. */
uint32_t reserved_size; /**< Current number of bytes allocated for the heap. */
uint32_t alloc_cnt; /**< Current number of allocations. */
uint32_t alloc_fail_cnt; /**< Number of failed allocations. */
} mbed_stats_heap_t;
Expand Down

0 comments on commit 14aa57f

Please sign in to comment.