Skip to content

Commit

Permalink
fix and comment on test
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyMusatkin committed Oct 27, 2023
1 parent ad39466 commit d0a751e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/system_resource_util_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d0a751e

Please sign in to comment.