Print heap memory usage statistics before exit (host version).

This commit is contained in:
Ruben Ayrapetyan
2014-07-25 19:09:10 +04:00
parent d90dccde9a
commit 5e4078095a
4 changed files with 63 additions and 51 deletions
+11 -1
View File
@@ -417,11 +417,17 @@ mem_heap_recommend_allocation_size( size_t minimum_allocation_size) /**< minimum
* Print heap
*/
void
mem_heap_print( bool dump_block_data) /**< print block with data (true)
mem_heap_print( bool dump_block_headers, /**< print block headers */
bool dump_block_data, /**< print block with data (true)
or print only block header (false) */
bool dump_stats) /**< print heap stats */
{
mem_check_heap();
JERRY_ASSERT( !dump_block_data || dump_block_headers );
if ( dump_block_headers )
{
__printf("Heap: start=%p size=%lu, first block->%p, last block->%p\n",
mem_heap.heap_start,
mem_heap.heap_size,
@@ -451,8 +457,11 @@ mem_heap_print( bool dump_block_data) /**< print block with data (true)
__printf("\n");
}
}
}
#ifdef MEM_STATS
if ( dump_stats )
{
__printf("Heap stats:\n");
__printf(" Size = %lu\n"
" Blocks count = %lu\n"
@@ -474,6 +483,7 @@ mem_heap_print( bool dump_block_data) /**< print block with data (true)
mem_heap_stats.peak_allocated_chunks,
mem_heap_stats.peak_allocated_bytes,
mem_heap_stats.peak_waste_bytes);
}
#endif /* MEM_STATS */
__printf("\n");
+1 -1
View File
@@ -42,7 +42,7 @@ extern void mem_heap_init(uint8_t *heap_start, size_t heap_size);
extern uint8_t* mem_heap_alloc_block(size_t size_in_bytes, mem_heap_alloc_term_t alloc_term);
extern void mem_heap_free_block(uint8_t *ptr);
extern size_t mem_heap_recommend_allocation_size(size_t minimum_allocation_size);
extern void mem_heap_print(bool dump_block_data);
extern void mem_heap_print(bool dump_block_headers, bool dump_block_data, bool dump_stats);
#ifdef MEM_STATS
/**
+2
View File
@@ -144,6 +144,8 @@ main (int argc __unused,
jerry_run( source_p,
source_size);
mem_heap_print( false, false, true);
return 0;
}
#endif
+1 -1
View File
@@ -82,7 +82,7 @@ main( int __unused argc,
}
}
mem_heap_print( false);
mem_heap_print( true, false, true);
return 0;
} /* main */