Fix non-linux build

This commit is contained in:
Antonio Andelic 2024-07-23 16:13:07 +02:00
parent 9d92bcff46
commit 04d80ec276
2 changed files with 2 additions and 4 deletions

View File

@ -33,7 +33,6 @@ namespace ErrorCodes
extern const int LOGICAL_ERROR; extern const int LOGICAL_ERROR;
} }
#if defined(OS_LINUX)
struct ICgroupsReader struct ICgroupsReader
{ {
virtual ~ICgroupsReader() = default; virtual ~ICgroupsReader() = default;
@ -44,6 +43,7 @@ struct ICgroupsReader
namespace namespace
{ {
#if defined(OS_LINUX)
/// Format is /// Format is
/// kernel 5 /// kernel 5
/// rss 15 /// rss 15
@ -269,7 +269,7 @@ uint64_t MemoryWorker::getMemoryUsage()
switch (source) switch (source)
{ {
case MemoryUsageSource::Cgroups: case MemoryUsageSource::Cgroups:
return cgroups_reader->readMemoryUsage(); return cgroups_reader != nullptr ? cgroups_reader->readMemoryUsage() : 0;
case MemoryUsageSource::Jemalloc: case MemoryUsageSource::Jemalloc:
#if USE_JEMALLOC #if USE_JEMALLOC
return resident_mib.getValue(); return resident_mib.getValue();

View File

@ -49,9 +49,7 @@ private:
MemoryUsageSource source{MemoryUsageSource::None}; MemoryUsageSource source{MemoryUsageSource::None};
#if defined(OS_LINUX)
std::shared_ptr<ICgroupsReader> cgroups_reader; std::shared_ptr<ICgroupsReader> cgroups_reader;
#endif
#if USE_JEMALLOC #if USE_JEMALLOC
JemallocMibCache<uint64_t> epoch_mib{"epoch"}; JemallocMibCache<uint64_t> epoch_mib{"epoch"};