global: implemented rudimentary memory manager to use available system memory

without forcing the OS to page swap
This commit is contained in:
itsmattkc
2020-02-21 14:20:57 +11:00
parent 2e38e7e3fb
commit e74c4c2d1c
6 changed files with 170 additions and 83 deletions
+33
View File
@@ -0,0 +1,33 @@
#ifndef MEMORYMANAGER_H
#define MEMORYMANAGER_H
#include <QObject>
class MemoryManager : public QObject
{
Q_OBJECT
public:
MemoryManager(QObject* parent = nullptr);
static void CreateInstance();
static MemoryManager* instance();
static void DestroyInstance();
static bool ShouldFreeMemory();
public slots:
void ConsumedMemory();
signals:
void FreeMemory();
private:
static uint64_t GetAvailableMemory();
static MemoryManager* instance_;
static const uint64_t minimum_available_memory_;
};
#endif // MEMORYMANAGER_H