Add Fuchsia support to memory_usage.

Implement GetProcessResidentSizeBytes for Fuchsia.

Bug: webrtc:14825
Change-Id: I64582ce0da72d3bb0fa61ff64799a1a165e1192f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/290922
Commit-Queue: Sarah Pham <smpham@google.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39154}
This commit is contained in:
Sarah Pham 2023-01-20 10:18:19 +11:00 committed by WebRTC LUCI CQ
parent 541024a588
commit 74f108a671

View file

@ -22,6 +22,9 @@
#include <windows.h>
#include <psapi.h> // must come after windows.h
// clang-format on
#elif defined(WEBRTC_FUCHSIA)
#include <lib/zx/process.h>
#include <zircon/status.h>
#endif
#include "rtc_base/logging.h"
@ -61,8 +64,16 @@ int64_t GetProcessResidentSizeBytes() {
}
return pmc.WorkingSetSize;
#elif defined(WEBRTC_FUCHSIA)
RTC_LOG_ERR(LS_ERROR) << "GetProcessResidentSizeBytes() not implemented";
return 0;
zx_info_task_stats_t task_stats;
zx_status_t status = zx::process::self()->get_info(
ZX_INFO_TASK_STATS, &task_stats, sizeof(task_stats), nullptr, nullptr);
if (status == ZX_OK) {
return task_stats.mem_mapped_bytes;
} else {
RTC_LOG_ERR(LS_ERROR) << "get_info() failed: "
<< zx_status_get_string(status);
return -1;
}
#else
// Not implemented yet.
static_assert(false,