utility: resident_set_memory

This commit is contained in:
Michele Caini 2024-10-03 14:22:44 +02:00
parent a38f5452d8
commit 1678cdbddd
2 changed files with 13 additions and 0 deletions

View File

@ -313,6 +313,12 @@ UVW_INLINE uint64_t utilities::available_memory() noexcept {
return uv_get_available_memory();
}
UVW_INLINE int64_t utilities::resident_set_memory() noexcept {
size_t res{};
const auto err = uv_resident_set_memory(&res);
return (err == 0) ? static_cast<int64_t>(res) : static_cast<int64_t>(err);
}
UVW_INLINE double utilities::uptime() noexcept {
double ret;

View File

@ -610,6 +610,13 @@ struct utilities {
*/
static uint64_t available_memory() noexcept;
/**
* @brief Gets the resident set size (RSS) for the current process.
* @return The resident set size (RSS) for the current process or a negative
* value in case of errors.
*/
static int64_t resident_set_memory() noexcept;
/**
* @brief Gets the current system uptime.
* @return The current system uptime or 0 in case of errors.