Jump to content
Corsair Community

[Feature request] RAM Usage


fludd

Recommended Posts

Hi there!

 

Just a quick feature request here:

 

It would be great, if you added a RAM usage widget.

 

I don't know, if this software is written in C++ or anything else, but you could use this to get the values and create a widget just like the cpu percentage widget. It might even help you in the quest of the search for the cpu usage problems in the icue software. Just create an instance of the object below and call the needed functions as few times as possible to save clock cycles.

 


// system_stats.h
#pragma once
#include "TCHAR.h"
#include "pdh.h"
#include "windows.h"

class SystemStats {

public:
SystemStats();
int currentCpuUsage();
int currentRamUsageInPercent();
int freeMemoryInPercent();

private:
PDH_HQUERY cpuQuery;
PDH_HCOUNTER cpuTotal;

};



// system_stats.cpp
#include "system_stats.h"

SystemStats::SystemStats()
{
   PdhOpenQuery(NULL, NULL, &cpuQuery);
   PdhAddEnglishCounter(cpuQuery, L"\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
   PdhCollectQueryData(cpuQuery);
}

int SystemStats::currentCpuUsage()
{
   PDH_FMT_COUNTERVALUE counterVal;

   PdhCollectQueryData(cpuQuery);
   PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, NULL, &counterVal);

   return (int)counterVal.doubleValue;
}

int SystemStats::currentRamUsageInPercent()
{
   MEMORYSTATUSEX memInfo;
   memInfo.dwLength = sizeof(MEMORYSTATUSEX);
   GlobalMemoryStatusEx(&memInfo);

   return memInfo.dwMemoryLoad;
}

int SystemStats::freeMemoryInPercent()
{
   return 100 - currentRamUsageInPercent();
}

Edited by fludd
Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...