It is currently September 29th, 2024, 1:25 pm

Difference between different memory measures

General topics related to Rainmeter.
User avatar
Maurdekye
Posts: 52
Joined: July 27th, 2014, 3:13 am

Difference between different memory measures

Post by Maurdekye »

What is the difference between the three separate memory measures PhysicalMemory, SwapMemory and Memory? As far as I can tell, they're all just seemingly random combinations of the physical memory in use and the swap memory in use. There's not even a measure for just the pagefile.sys memory alone, and I barely see the reasoning behind RAM + RAM + pagefile.sys. Could someone explain in the briefest of terms why instead of what there is now, there aren't just two memory measures each for RAM and the pagefile?

Now, I'm not incredibly well acquainted with computer architecture or why any of this would be more useful/convenient/easier to process than the above, but if someone could procure an explanation then I'd be very thankful.
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Difference between different memory measures

Post by jsmorley »

It is just based on how Windows refers to the various memory allocations it manages, and what is returned to us by the Windows API calls.

RAM Memory is the physical chip memory

PageFile is a dynamically allocated file on the disk used to swap things in and out as needed. That in and of itself, alone, is not considered "memory".

Swap Memory is the combination of RAM and PageFile.

Virtual Memory is the combination of RAM Memory and Swap Memory

So:

RAM = RAM
Swap = RAM + PageFile
Virtual = RAM + (RAM + PageFile)

So what I get is:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[MeasurePhysical]
Measure=PhysicalMemory
Total=1

[MeasureSwapMem]
Measure=SwapMemory
Total=1

[MeasureSwapFile]
Measure=Calc
Formula=MeasureSwapMem - MeasurePhysical

[MeasureVirtual]
Measure=Memory
Total=1

[MeterOne]
Meter=String
MeasureName=MeasurePhysical
MeasureName2=MeasureSwapFile
MeasureName3=MeasureSwapMem
MeasureName4=MeasureVirtual
FontSize=12
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
AutoScale=1
Text=Physical: %1#CRLF#Swap File: %2#CRLF#Swap Mem: %3#CRLF#Virtual: %4
2014-08-12_101356.jpg
Why? I have no idea. I suspect it goes back to original architectures where there was a big difference between "swapping" and "paging", There are endless arcane discussions on the geek sites that talk about how "virtual" is just not the same as "swap", as Windows creates program specific virtual machines that allow two programs to share the same physical memory without conflict. This creates a "virtual memory space" that is larger than just the old school physical + swap file. I'm veering dangerously into "full of crap" territory here, but the long and the short of it is that what we use is what Windows tells us.

You may be more comfortable thinking in terms of the total of memory being RAM + PageFile, and if so, you can use the first three measures above (with the calculated currently allocated page file size) and just go with that. Windows is certainly schizophrenic about it, as in "System Information" / msinfo32.exe it shows it that way...
mem.jpg
So without bothering with pretty cosmetics, we can match Windows System Information:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[MeasurePhysicalTotal]
Measure=PhysicalMemory
Total=1

[MeasurePhysicalUsed]
Measure=PhysicalMemory

[MeasurePhysicalFree]
Measure=PhysicalMemory
InvertMeasure=1

[MeasureSwapTotal]
Measure=SwapMemory
Total=1

[MeasureSwapUsed]
Measure=SwapMemory

[MeasureSwapFree]
Measure=SwapMemory
InvertMeasure=1

[MeasurePageFileTotal]
Measure=Calc
Formula=MeasureSwapTotal - MeasurePhysicalTotal

[MeasurePageFileUsed]
Measure=Calc
Formula=MeasureSwapUsed - MeasurePhysicalUsed

[MeasurePageFileFree]
Measure=Calc
Formula=MeasurePageFileTotal - MeasurePageFileUsed

[MeterOne]
Meter=String
MeasureName=MeasurePhysicalTotal
MeasureName2=MeasurePhysicalUsed
MeasureName3=MeasurePhysicalFree
MeasureName4=MeasureSwapTotal
MeasureName5=MeasureSwapUsed
MeasureName6=MeasureSwapFree
MeasureName7=MeasurePageFileTotal
MeasureName8=MeasurePageFileUsed
MeasureName9=MeasurePageFileFree
FontSize=12
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
AutoScale=1
NumOfDecimals=1
Text=Physical: Total %1B | Used %2B | Free %3B#CRLF#Virtual: Total %4B | Used %5B | Free %6B#CRLF#PageFile: Total %7B | Used %8B | Free %9B
mem2.jpg
page.jpg
You do not have the required permissions to view the files attached to this post.