Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyMusatkin committed Oct 23, 2023
1 parent a430c99 commit 24aace4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/aws/common/system_resource_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct aws_memory_usage {
* Get memory usage for current process.
* Raises AWS_ERROR_SYS_CALL_FAILURE on failure.
*/
AWS_COMMON_API int aws_memory_usage_for_current_process(struct aws_memory_usage *memory_usage);
AWS_COMMON_API int aws_init_memory_usage_for_current_process(struct aws_memory_usage *memory_usage);

AWS_EXTERN_C_END
AWS_POP_SANE_WARNING_LEVEL
Expand Down
4 changes: 3 additions & 1 deletion source/posix/system_resource_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
#include <aws/common/system_resource_util.h>

#include <sys/resource.h>
#include <libproc.h>

int aws_memory_usage_for_current_process(struct aws_memory_usage *memory_usage) {
int aws_init_memory_usage_for_current_process(struct aws_memory_usage *memory_usage) {
AWS_PRECONDITION(memory_usage);

AWS_ZERO_STRUCT(memory_usage);
struct rusage usage;

if (getrusage(RUSAGE_SELF, &usage)) {
Expand Down
3 changes: 2 additions & 1 deletion source/windows/system_resource_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

#include <psapi.h>

int aws_memory_usage_for_current_process(struct aws_memory_usage *memory_usage) {
int aws_init_memory_usage_for_current_process(struct aws_memory_usage *memory_usage) {
AWS_PRECONDITION(memory_usage);

AWS_ZERO_STRUCT(memory_usage);
HANDLE hProcess = GetCurrentProcess();

PROCESS_MEMORY_COUNTERS pmc;
Expand Down
3 changes: 1 addition & 2 deletions tests/system_resource_util_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ static int s_test_memory_usage_maxrss(struct aws_allocator *allocator, void *ctx
(void)ctx;

struct aws_memory_usage mu;
AWS_ZERO_STRUCT(mu);
ASSERT_SUCCESS(aws_memory_usage_for_current_process(&mu));
ASSERT_SUCCESS(aws_init_memory_usage_for_current_process(&mu));

ASSERT_TRUE(mu.maxrss > 0);

Expand Down

0 comments on commit 24aace4

Please sign in to comment.