It is currently September 29th, 2024, 5:43 pm

Memory & SwapMemory

General topics related to Rainmeter.
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Memory & SwapMemory

Post by jsmorley »

Microsoft's Perfmon can be a funny duck. In the actual Perfmon.exe tool, it shows (for me) that value as a percentage of my total paging file, which is 4095 Meg. I"m using 214 Meg of the 4085 Meg, so for me the percentage used of the paging file in the tool is 5.227. Ok, fine. However, what is actually reported out to things like Rainmeter that grab the value is a non-percentual number, in my case 54784. Apparently what Microsoft is doing in the tool is dividing this number by 10480 to turn 54784 (which seems to be in megabytes * 10 for some reason) into a number that it displays as a percentage. Not sure it fully makes sense to be honest, but I'm still on my first cup of coffee.

However, if I use this:

[MeasurePage]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Paging File"
PerfMonCounter="% Usage"
PerfMonInstance="_Total"
PerfMonDifference=0

[MeterOne]
Meter=String
MeasureName=MeasurePage
FontSize=20
FontColor=255,255,255,255
Scale=10480
NumOfDecimals=3
Postfix=%
AntiAlias=1

I get exactly what is showing in Perfmon.exe, which is 5.227% It seems you don't want to use Percentual=1, as what is being returned is not a percentage as such, but a number that Perfmon.exe internally divides to create a percentage. So in effect what you have to do is duplicate what the tool is doing.

On your second question, I don't think we have touched the Perfmon plugin in a long time. Unless I am forgetting something.
E_E_J
Posts: 2
Joined: April 25th, 2011, 9:22 am

Re: Memory & SwapMemory

Post by E_E_J »

Thanks for the info, I replaced percent with scale, and just adjusted the values till it displayed the correct value. For me it was scale=256, kinda weird that each OS uses a different scale to display a single value as a %. By setting my pagefile to a static 1gig, I know 9% is 90megs of my pagefile, so I just changed the display to Text="Pagefile %1 MB". Im happy with the way its displaying now. Not knowing if your memory is being stored in ram or hard drive always bothered me, since you can get performance slowdowns if your pc was always having to swap data in and out of ram.

So to anyone trying to read there pagefile without having to subtract swap or ram, the information previously posted works, (least for me) just have to play with the scale till it says the value as %. then you can just play with that value to get whatever you want out of it.
Eversor86
Posts: 3
Joined: March 7th, 2011, 7:31 pm

Re: Memory & SwapMemory

Post by Eversor86 »

Well. First I'm somehow disappointed that I waited for so long for some answer from you guys. Which makes me sad even more that you replayed to E_E_J like next day...
Ach well. The stuff you described is the stuff I did, and was mentioning as not so good solution/work around. Like I said for everyone its different value. The scale you need to use I mean. Furthermore it changes when you change the pagefile size. It was just something around 42,200 in perfmon vs 53000 actually read. Now its 65,600 in perfmon vs 258000 read by plug-in. It's not a big deal, as long as you don't create skin for people to use, or change pagefile size once per while (sec stuff happening a lot less often).

But I will not agree with your description how it happens. I mean perfmon at least in windows 7 show value as percentage. Like now it shows me 59,876. And on the graph the same stuff. Problem is that perfmon plug-in reads that 59,876 value as something totally different. First its not percentage (floating point) but integer value, so it should be or multiplied percentage value by 1000 or at least 1024. But somehow its varying. Once its 1300 other time 10000, and another time it hits 40000. There is no math behind it, its like pure randomness. Well I believe there is some way to get the value from some math hidden in windows, but at least for now I somehow lack the variables that could create the formula. So all we need to do is to make an meter, show it on screen, open perfmon, show pagefile usage in it, make print screen and use this to calculate the scale (I mean the values in perfmon and read by plug-in). Or like me put them in setting file for my skin, as the actual scale is calculated by my pagefile skin module itself.

One more thing: Megabyte is 1000000. Mebibyte is 1048576. You probably though about Kilo/Kibi, but well KiloByte is 1000, KibiByte is 1024. Not 1048 - just small mistake :P which I must point out in my jealousy rage that you replied to E_E_J but not to me ^_^.

All I can say to all other people who have tried to use perfmon at least for pagefile (don't know if similar issues are with other values read by perfmon plug-in) is that probably the stuff at fault here is windows and perfom itself. Cuz somehow I don't believe that plug-in itself could make such mess with just reading one value.
User avatar
jsmorley
Developer
Posts: 22790
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Memory & SwapMemory

Post by jsmorley »

Well, I only can go by what worked for me. I suspect Perfmon is using some variant of 1048576 when it does the dividing, as noted in this info from Wikipedia. I rounded it to 10480 as unless I want to display a lot more decimal places, it was close enough.

Definition

The term "megabyte" is commonly used to mean either 10002 bytes or 10242 bytes. This originated as compromise technical jargon for the byte multiples that needed to be expressed by the powers of 2 but lacked a convenient name. As 1024 (210) approximates 1000 (103), roughly corresponding SI multiples began to be used for binary multiples. By the end of 2007, standards and government authorities including IEC, IEEE, EU, and NIST proposed standards for binary prefixes and requiring the use of megabyte to strictly denote 10002 bytes and mebibyte to denote 10242 bytes. This is reflected in an increasing number of software projects using the new definitions, but some file managers still show file sizes using the binary interpretation (10242 bytes). The term remains ambiguous and it can follow any one of the following common definitions:

* 1000000 bytes (10002, 106): This is the definition recommended by the International System of Units (SI) and the International Electrotechnical Commission IEC.[3] This definition is used in networking contexts and most storage media, particularly hard drives, Flash-based storage,[4] and DVDs, and is also consistent with the other uses of the SI prefix in computing, such as CPU clock speeds or measures of performance. The Mac OS X 10.6 file manager is a notable example of this usage in software. Since Snow Leopard, file sizes are reported in decimal units.[5]

* 1048576 bytes (10242, 220): This definition is most commonly used in reference to computer memory, but most software that display file size or drive capacity, including file managers also use this definition. See Consumer confusion (in the "gigabyte" article). The Microsoft Windows file manager is a notable example of this usage in software.
Eversor86
Posts: 3
Joined: March 7th, 2011, 7:31 pm

Re: Memory & SwapMemory

Post by Eversor86 »

Hehe. This starts to get a bit off-topic. But well. I don't think perfmon divides anything. It shows values as percentage. Aka for example 50,123. Its rather multiplying this to get those round values. I thought it will just remove the comma, by multiplying it by 1000, but like I told a lot, and other people probably checked themselves its actually different value from below 500 to over 50000 depending on PC, OS, Ram, Pagefile size, and probably start alignments ^_^. The most important stuff is that its probably not easy to predict and thus making perfmon plug-in that will work same on all PCs is more or less impossible, and thus every person who wants to use perfmon for at least page file stuff (as I said before - no clue if its same shit with other stuff read by that plug-in) needs to use scale, which will be calculated by comparing value read by perfmon plug-in and value shown in perfmon itself.

Well end of topic for myself XD at least till next time I will encounter an issue, or just will come here to check if topic moved (rather perfmon plug-in got upgraded or something).
avkun
Posts: 1
Joined: September 24th, 2013, 2:31 pm

Re: Memory & SwapMemory

Post by avkun »

Hi, sorry for redigging this old topic, but after reading all this I'm still confused. I've tried to get the pagefile usage in my skin as follows:

Code: Select all

[measureRam]
Measure=PhysicalMemory

[measureMRam]
Measure=PhysicalMemory
Total=1
UpdateDivider=3600

[measureSwapTemp]
Measure=SwapMemory

[measureMSwapTemp]
Measure=SwapMemory
Total=1
UpdateDivider=1800

[measureSwap]
Measure=calc
formula=measureSwapTemp - measureRam

[measureMSwap]
Measure=calc
formula=measureMSwapTemp-measureMRam
UpdateDivider=1800
I thought that if I subtract the amount of physical memory from swap memory, I'd get pagefile usage... This logic is correct for max value (I get 4 GB just as I've set in my system). And while the current value seemed reasonable to me for quite a while, today my skin reported that the usage of pagefile is negative! It lasted for about 30 minutes and the more I used my computer, the "less negative" it became :P

To be more precise, I got something like this:

Code: Select all

measureRam=4184363008
measureSwapTemp=4081078272
If measureRam>measureSwapTemp, then it is impossible for Measure=SwapMemory to be equal to RAM + Pagefile.sys... Q.E.D.

Having said that, I think I'll just implement PerfMon in my skin.