add old lci module

This commit is contained in:
qing committed 2026-08-02 20:15:07 +08:00
1 parent 38a6e815f0
commit 8499631091
171 files changed
+25562

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
#include "hd/mem.h"
/* 通过SysInfo接口获取内存使用情况 失败会返回NULL */
MemoryInfo getMemoryUsageWithSysinfo() {
MemoryInfo memInfo = {0};
struct sysinfo si;
if (sysinfo(&si) == 0)
{
memInfo.totalMemory = si.totalram * si.mem_unit;
memInfo.freeMemory = si.freeram * si.mem_unit;
memInfo.usedMemory = memInfo.totalMemory - memInfo.freeMemory;
if (memInfo.totalMemory > 0)
memInfo.usageRate = 100.0 * memInfo.usedMemory / memInfo.totalMemory;
}
else
std::cerr << "sysinfo Call Failed" << std::endl;
return memInfo;
}