diff --git a/src/uvw/util.cpp b/src/uvw/util.cpp index 4e2fff35..6d90b8d2 100644 --- a/src/uvw/util.cpp +++ b/src/uvw/util.cpp @@ -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(res) : static_cast(err); +} + UVW_INLINE double utilities::uptime() noexcept { double ret; diff --git a/src/uvw/util.h b/src/uvw/util.h index 0b549e19..0aec1933 100644 --- a/src/uvw/util.h +++ b/src/uvw/util.h @@ -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.