memory_arena
Loading...
Searching...
No Matches
arena_stats.h
Go to the documentation of this file.
1
32#ifndef ARENA_STATS_H
33#define ARENA_STATS_H
34
35#include <stddef.h>
36#include <stdio.h>
37
38#ifdef __cplusplus
39extern "C"
40{
41#endif
42
70
71 struct s_arena;
72 typedef struct s_arena t_arena;
73
85 void arena_print_stats(t_arena* arena, FILE* stream);
86
100
113
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif // ARENA_STATS_H
t_arena_stats stats
Allocation and memory usage statistics.
Definition arena.h:146
size_t size
Total size of the buffer.
Definition arena.h:131
size_t last_alloc_size
Size of the last allocation.
Definition arena_stats.h:64
size_t shrinks
Number of times the arena was shrunk.
Definition arena_stats.h:60
size_t peak_usage
Highest offset reached (i.e., peak memory usage)
Definition arena_stats.h:58
size_t reallocations
Total number of reallocations (via arena_realloc_last)
Definition arena_stats.h:56
size_t growth_history_count
Number of growth events recorded.
Definition arena_stats.h:62
size_t failed_allocations
Number of failed allocation attempts.
Definition arena_stats.h:68
size_t wasted_alignment_bytes
Total bytes wasted due to alignment padding.
Definition arena_stats.h:59
size_t last_alloc_id
Unique ID of the last allocation.
Definition arena_stats.h:66
size_t bytes_allocated
Cumulative bytes allocated.
Definition arena_stats.h:57
size_t * growth_history
Array of size values recorded during arena growth.
Definition arena_stats.h:61
size_t alloc_id_counter
Total allocation ID counter (used for tracking)
Definition arena_stats.h:67
size_t allocations
Total number of successful allocations.
Definition arena_stats.h:55
size_t live_allocations
Number of active allocations (not yet released)
Definition arena_stats.h:63
size_t last_alloc_offset
Offset of the last allocation.
Definition arena_stats.h:65
void arena_stats_reset(t_arena_stats *stats)
Reset the given statistics structure to zero.
void arena_print_stats(t_arena *arena, FILE *stream)
Print formatted diagnostics about the arena to a stream.
Definition arena_stats.c:74
struct s_arena_stats t_arena_stats
Structure holding runtime statistics for an arena.
t_arena_stats arena_get_stats(const t_arena *arena)
Return a snapshot of the arena's internal statistics.
void arena_stats_record_growth(t_arena_stats *stats, size_t size)
Append a new growth event to the growth_history array.
Structure holding runtime statistics for an arena.
Definition arena_stats.h:54
The main memory arena structure used for fast allocation.