Introduction
This article concentrates on tracking system memory parameters in real time. The system memory parameters will depend on the policy of memory management by the kernel. This includes the type of paging, type of relocation and algorithms behind the aforesaid processes.
About Memory Management
This topic is about the mechanism and the requirements behind system memory management. Often the physical memory available in your system is very low considered to the amount of actual memory needed for running individual processes. This situation becomes critical in a multitasking operating system like Windows. So the available physical memory should be managed in an optimized fashion to avail full system throughput. The actual physical memory thus get extended to a particular limit by the concept of Virtual Memory. This concept is applied by swapping sections of RAM memory in and out of the system hard disk. The swapped sections are called pages which we will be discussing in our next section. Since swapping involves CPU time memory should be optimized to produce minimum chances of swapping. But anyhow, it cannot be avoided too.
Paging
The process which is to be brought to the RAM is not brought as such as a whole. Instead, it is broken into pieces called pages for efficient management of memory and ease of swapping. When it is broken into pieces, the whole process need not be swapped in/out of the disk frequently. Hence each page of process will occupy a corresponding frame of divided memory. For more information regarding the above processes, perhaps you would go to
http://www.linux.com/.
About the code
All the above information is displayed graphically in the application uploaded here with. The application would show you how much physical memory your system has and the corresponding payloads. The code runs as follows: [I am including only the code with relevance. Rest being the same as generated by AppWizard]
#define MEMTRACKTIMER 10
The function GlobalMemoryStatus(LPMEMORYSTATUS memStat);
defined in winbase.h, will collect all the information about the memory and fill the same in a MEMORYSTATUS structure. The structure runs as below:
typedef struct _MEMORYSTATUS {
DWORD dwLength;
DWORD dwMemoryLoad;
SIZE_T dwTotalPhys;
SIZE_T dwAvailPhys;
SIZE_T dwTotalPageFile;
SIZE_T dwAvailPageFile;
SIZE_T dwTotalVirtual;
SIZE_T dwAvailVirtual;
}MEMORYSTATUS, *LPMEMORYSTATUS;
The object of above structure when passed into the function would fill the structure accordingly. That's it...