From d006b46df31f6e5f28237fe40eafb135e684b739 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 28 Nov 2014 11:53:55 +0100 Subject: score: Add heap statistics Add lifetime bytes allocated and freed since they were present in the malloc statistics. Add number of failed allocations. --- cpukit/score/src/heapallocate.c | 12 ++++++++---- cpukit/score/src/heapfree.c | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'cpukit/score/src') diff --git a/cpukit/score/src/heapallocate.c b/cpukit/score/src/heapallocate.c index 597077e280..a76ac04f49 100644 --- a/cpukit/score/src/heapallocate.c +++ b/cpukit/score/src/heapallocate.c @@ -254,10 +254,6 @@ void *_Heap_Allocate_aligned_with_boundary( } while ( search_again ); if ( alloc_begin != 0 ) { - /* Statistics */ - ++stats->allocs; - stats->searches += search_count; - block = _Heap_Block_allocate( heap, block, alloc_begin, alloc_size ); _Heap_Check_allocation( @@ -268,6 +264,14 @@ void *_Heap_Allocate_aligned_with_boundary( alignment, boundary ); + + /* Statistics */ + ++stats->allocs; + stats->searches += search_count; + stats->lifetime_allocated += _Heap_Block_size( block ); + } else { + /* Statistics */ + ++stats->failed_allocs; } /* Statistics */ diff --git a/cpukit/score/src/heapfree.c b/cpukit/score/src/heapfree.c index 4e69146232..13bf5eed81 100644 --- a/cpukit/score/src/heapfree.c +++ b/cpukit/score/src/heapfree.c @@ -201,6 +201,7 @@ bool _Heap_Free( Heap_Control *heap, void *alloc_begin_ptr ) --stats->used_blocks; ++stats->frees; stats->free_size += block_size; + stats->lifetime_freed += block_size; return( true ); } -- cgit v1.2.3