Skip to content

Commit aede1d8

Browse files
authored
Fix MemoryLimit primary_allocated stat (#453)
1 parent 64c35be commit aede1d8

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

source/s3_buffer_pool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ void s_buffer_pool_trim_synced(struct aws_s3_buffer_pool *buffer_pool) {
232232
aws_array_list_get_at_ptr(&buffer_pool->blocks, (void **)&block, i);
233233

234234
if (block->alloc_bit_mask == 0) {
235+
buffer_pool->primary_allocated -= block->block_size;
235236
aws_mem_release(buffer_pool->base_allocator, block->block_ptr);
236237
aws_array_list_erase(&buffer_pool->blocks, i);
237238
/* do not increment since we just released element */

tests/s3_buffer_pool_tests.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static int s_test_s3_buffer_pool_trim(struct aws_allocator *allocator, void *ctx
158158
struct aws_s3_buffer_pool_usage_stats stats_after = aws_s3_buffer_pool_get_usage(buffer_pool);
159159

160160
ASSERT_TRUE(stats_before.primary_num_blocks > stats_after.primary_num_blocks);
161+
ASSERT_TRUE(stats_before.primary_allocated > stats_after.primary_allocated);
161162

162163
for (size_t i = 20; i < 40; ++i) {
163164
aws_s3_buffer_pool_release_ticket(buffer_pool, tickets[i]);

0 commit comments

Comments
 (0)