42 lines
941 B
C++
42 lines
941 B
C++
#pragma once
|
|
|
|
class MemoryInfo
|
|
{
|
|
private:
|
|
struct MEM_INFO
|
|
{
|
|
unsigned int total;
|
|
unsigned int free;
|
|
unsigned int buffers;
|
|
unsigned int cached;
|
|
unsigned int swap_cached;
|
|
unsigned int swap_total;
|
|
unsigned int swap_free;
|
|
unsigned int available;
|
|
};
|
|
typedef struct MEM_INFO Mem_info;
|
|
MemoryInfo(/* args */);
|
|
~MemoryInfo(){}
|
|
MemoryInfo& operator=(const MemoryInfo &);
|
|
void getMemInfo(Mem_info& info);
|
|
public:
|
|
static MemoryInfo* GetInstance();
|
|
float GetMemoryUsed();
|
|
private:
|
|
class Garbo
|
|
{
|
|
private:
|
|
public:
|
|
~Garbo()
|
|
{
|
|
if(MemoryInfo::m_pInstance!=nullptr)
|
|
{
|
|
delete MemoryInfo::m_pInstance;
|
|
MemoryInfo::m_pInstance=nullptr;
|
|
}
|
|
}
|
|
};
|
|
static MemoryInfo* m_pInstance;
|
|
static Garbo garbo;
|
|
};
|