Skip to content

Commit 1145288

Browse files
committed
Eliminate code duplication in memory statistics printing
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent db6caf3 commit 1145288

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

jerry-core/mem/mem-allocator.cpp

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,7 @@ mem_finalize (bool is_show_mem_stats) /**< show heap memory stats
5353

5454
if (is_show_mem_stats)
5555
{
56-
mem_heap_print (false, false, true);
57-
58-
#ifdef MEM_STATS
59-
mem_pools_stats_t stats;
60-
mem_pools_get_stats (&stats);
61-
62-
printf ("Pools stats:\n");
63-
printf (" Chunk size: %zu\n"
64-
" Pools: %zu\n"
65-
" Allocated chunks: %zu\n"
66-
" Free chunks: %zu\n"
67-
" Peak pools: %zu\n"
68-
" Peak allocated chunks: %zu\n\n",
69-
MEM_POOL_CHUNK_SIZE,
70-
stats.pools_count,
71-
stats.allocated_chunks,
72-
stats.free_chunks,
73-
stats.peak_pools_count,
74-
stats.peak_allocated_chunks);
75-
#endif /* MEM_STATS */
56+
mem_stats_print ();
7657
}
7758

7859
mem_heap_finalize ();
@@ -151,6 +132,7 @@ mem_stats_reset_peak (void)
151132
mem_heap_stats_reset_peak ();
152133
mem_pools_stats_reset_peak ();
153134
} /* mem_stats_reset_peak */
135+
#endif /* MEM_STATS */
154136

155137
/**
156138
* Print memory usage statistics
@@ -160,6 +142,7 @@ mem_stats_print (void)
160142
{
161143
mem_heap_print (false, false, true);
162144

145+
#ifdef MEM_STATS
163146
mem_pools_stats_t stats;
164147
mem_pools_get_stats (&stats);
165148

@@ -176,5 +159,5 @@ mem_stats_print (void)
176159
stats.free_chunks,
177160
stats.peak_pools_count,
178161
stats.peak_allocated_chunks);
179-
} /* mem_stats_print */
180162
#endif /* MEM_STATS */
163+
} /* mem_stats_print */

jerry-core/mem/mem-allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ extern void mem_unregister_a_try_give_memory_back_callback (mem_try_give_memory_
123123

124124
#ifdef MEM_STATS
125125
extern void mem_stats_reset_peak (void);
126-
extern void mem_stats_print (void);
127126
#endif /* MEM_STATS */
127+
extern void mem_stats_print (void);
128128

129129
#endif /* !JERRY_MEM_ALLOCATOR_H */
130130

0 commit comments

Comments
 (0)