ICGroupMemoryInfo_abi#
Fully qualified name: omni::platforminfo::ICGroupMemoryInfo_abi
Defined in omni/platforminfo/ICGroupMemoryInfo.h
-
class ICGroupMemoryInfo_abi : public omni::core::Inherits<omni::core::IObject, std::integral_constant<uint64_t, carb::fnv1aHash("omni.platforminfo.ICGroupMemoryInfo")>::value>#
Interface to collect memory information directly from Linux’s root control group.
Interface to collect and retrieve information about cgroup limited memory installed in the system. The values reported from this interface will reflect any memory limitations imposed on the system by an external source. For example, the system memory could be limited in a container, a VM, or by an OS level per-user quota.
This interface is intended to be used to directly retrieve the cgroup information about the system memory if set. If a particular value is not set in the cgroup (ie: memory limit, swap limit, etc), the corresponding function will fail allowing the caller to fall back to another information source such as the bare metal values.
This interface is available on Windows for convenience, but all functions will simply fail when called. This makes it easier to call into the interface without needing additional
nullptr
checks.Note
This interface supports cgroup versions 1 and 2 on Linux.
Subclassed by omni::core::Generated< omni::platforminfo::ICGroupMemoryInfo_abi >
Public Functions
-
inline void *cast(omni::core::TypeId id) noexcept#
Returns a pointer to the interface defined by the given type id if this object implements the type id’s interface.
Objects can support multiple interfaces, even interfaces that are in different inheritance chains.
The returned object will have omni::core::IObject::acquire() called on it before it is returned, meaning it is up to the caller to call omni::core::IObject::release() on the returned pointer.
The returned pointer can be safely
reinterpret_cast<>
to the type id’s C++ class. For example, “omni.windowing.IWindow” can be cast toomni::windowing::IWindow
.Do not directly use this method, rather use a wrapper function like omni::core::cast() or omni::core::ObjectPtr::as().
- Thread Safety
This method is thread safe.
-
inline void acquire() noexcept#
Increments the object’s reference count.
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
inline void release() noexcept#
Decrements the objects reference count.
Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
Protected Functions
- virtual bool getTotalPhysicalMemory_abi(
- size_t &bytes,
Retrieves the maximum RAM accessible by the calling process.
Remark
This retrieves the maximum RAM that the calling process is allowed to access in a limited resource situation. Depending on the cgroup version that is supported in the system, this value either comes from the file
/sys/fs/cgroup/memory.max
(v2) or/sys/fs/cgroup/memory/memory.limit_in_bytes
(v1).- Thread Safety
This call is thread safe.
- Parameters:
bytes – [out] Receives the number of bytes of physical RAM installed in the system and allowed for use by the calling process. This value will not change during the lifetime of the calling process and can be safely cached. Receives 0 if no memory limit is set. This may not be
nullptr
.- Returns:
true
if a memory limit is set in the cgroup and that value is retrieved. Returnsfalse
if no memory limit is set in the cgroup. In this case, the bare metal physical memory limit should be used instead.
- virtual bool getAvailablePhysicalMemory_abi(
- size_t &bytes,
Retrieves the available allowed physical memory in the system.
Remark
This retrieves the available RAM that the calling process is allowed to access in a limited resource situation. Depending on the cgroup version that is supported in the system, this value either comes from the file
/sys/fs/cgroup/memory.current
(v2) or/sys/fs/cgroup/memory/memory.usage_in_bytes
(v1).- Thread Safety
This call is thread safe. However, two consecutive or concurrent calls are unlikely to return the same value.
- Parameters:
bytes – [out] Receives the number of bytes of physical memory that is currently available and accessible for use by the operating system. Note that this is not a measure of how much memory is available to the calling process, but rather for the entire system. This value will reflect the amount of memory available for the given cgroup memory limit. Receives 0 if no memory limit is set. This may not be
nullptr
.- Returns:
true
if a memory limit is set and the available memory amount was retrieved successfully. Returnsfalse
if no memory limit is set.
- virtual bool getTotalPageFileMemory_abi(
- size_t &bytes,
Retrieves the total accessible page file space in the system.
Remark
This retrieves the total accessible page file space in a limited system resource situation. This value is only available on systems that support cgroup v2 from the file
/sys/fs/cgroup/memory.swap.max
. Swap space limitations are not supported on cgroup v1 as a lone value. It is only available as a combined swap plus memory value.- Thread Safety
This call is thread safe.
- Parameters:
bytes – [out] Receives the number of bytes of page file space in the system. The value will not change during the lifetime of the calling process and can be safely cached. Receives 0 if no swap space limit is set in the cgroup. This may not be
nullptr
.- Returns:
true
if a swap space limit has been set in the cgroup and is successfully retrieved. Returnsfalse
if no swap space limit is set in the cgroup.
- virtual bool getAvailablePageFileMemory_abi(
- size_t &bytes,
Retrieves the available allowed page file space in the system.
Remark
This retrieves the available page file space in a limited system resource situation. Depending on the cgroup version that is supported in the system, this value either comes from the file
/sys/fs/cgroup/memory.swap.current
(v2) or theswap
field of/sys/fs/cgroup/memory/memory.stat
.- Thread Safety
This call is thread safe. However, two consecutive or concurrent calls are unlikely to return the same value.
- Parameters:
bytes – [out] Receives the number of bytes of page file space that is currently available for use by the operating system if a swap space limit is set in the cgroup. Receives 0 if no swap space limit is set in the cgroup. This may not be
nullptr
.- Returns:
true
if a swap space limit is set and the available swap space memory amount was retrieved successfully. Returnsfalse
if no swap space limit is set.
-
virtual void *cast_abi(TypeId id) noexcept = 0#
Returns a pointer to the interface defined by the given type id if this object implements the type id’s interface.
Objects can support multiple interfaces, even interfaces that are in different inheritance chains.
The returned object will have omni::core::IObject::acquire() called on it before it is returned, meaning it is up to the caller to call omni::core::IObject::release() on the returned pointer.
The returned pointer can be safely
reinterpret_cast<>
to the type id’s C++ class. For example, “omni.windowing.IWindow” can be cast toomni::windowing::IWindow
.Do not directly use this method, rather use a wrapper function like omni::core::cast() or omni::core::ObjectPtr::as().
- Thread Safety
This method is thread safe.
-
virtual void acquire_abi() noexcept = 0#
Increments the object’s reference count.
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
virtual void release_abi() noexcept = 0#
Decrements the objects reference count.
Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).
Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().
Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.
- Thread Safety
This method is thread safe.
-
inline void *cast(omni::core::TypeId id) noexcept#