From d0a751ec41cd60071d44f0580c287de11b6be57d Mon Sep 17 00:00:00 2001 From: Dmitriy Musatkin Date: Fri, 27 Oct 2023 11:36:50 -0700 Subject: [PATCH] fix and comment on test --- tests/system_resource_util_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/system_resource_util_test.c b/tests/system_resource_util_test.c index 880e74156..e3e7b84aa 100644 --- a/tests/system_resource_util_test.c +++ b/tests/system_resource_util_test.c @@ -11,16 +11,24 @@ static int s_test_memory_usage_maxrss(struct aws_allocator *allocator, void *ctx) { (void)ctx; + /* + * Note: mem usage apis currently rely on getrusage on posix systems. + * On freebsd maxrss seems to return current process rss based on testing, + * while on every other posix platform maxrss is high water mark for rss + * over the program lifetime. + * Workaround it by allocating a buffer first. Long term using procfs should + * avoid the issue. + */ struct aws_byte_buf temp; aws_byte_buf_init(&temp, allocator, 8 * 1024 * 1024); - aws_byte_buf_clean_up_secure(&temp); - struct aws_memory_usage_stats mu; ASSERT_SUCCESS(aws_init_memory_usage_for_current_process(&mu)); ASSERT_TRUE(mu.maxrss > 0); + aws_byte_buf_clean_up_secure(&temp); + return 0; }