It is currently September 29th, 2024, 11:26 pm

RAM consuming

General topics related to Rainmeter.
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

RAM consuming

Post by ~Faradey~ »

I wonder why Rainmeter not removes unnecessary pages from the working set (of Rainmeter.exe process)...
I mean when skins loads, Rainmeter creates and fills in working set for resourses that currently visible, or should i say meters?. And if i make hidden meter (or group of meters) visible, and for good example let it be a big image, then Rainmeter adds some required amount of pages to its set, but why not remove them when i hide meter again?

in other words why not to work dynamicaly? and dynamicaly release and occupy RAM?

Maybe this is how it should work? if so, it's ok, but if it's possible to work dynamicaly, i thing this would better, isn't it?...the reason why i'm asking is, when I wrote one of my programs in front of me was the question: "How to release resourses when they not needed anymore, thus to decrease RAM consuming?" - i found an answer, and later i tried it on Rainmeter, and i was suprised when it worked...but not to long. When i did full refresh and toggle some meters from hidden state i saw that number gone back almost to how they were before releasing resources...

Pls, don't get me wrong, i'm just learning stuff and i'm wondering pretty much about everything :) ;-)
User avatar
Brian
Developer
Posts: 2736
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: RAM consuming

Post by Brian »

I believe the reason is because it takes X amount of time to load certain resources (like large pictures), and it makes sense to load these at startup, instead of taking extra time if a meter gets hidden a lot.

For example: Let's say we have some large image that takes 50ms to load. And let's say we want to move that image around the screen with some simple animation that basically hides the image in its current location, then moves it to the new location, then show it again. Every time you do that, it would take an extra 50ms to load the image each time. Let's say we move that image just 10 times per second. That means we are taking 500ms (almost a half of second), just to load the image into memory. It makes more sense to just leave the image in memory and hide it on the screen, then to unload/load it at a high rate. Obviously this is just an example, and is not practical.

It does this already when dynamically changing the image file, but not when hiding. Actually, IIRC, hiding a meter just changes its W and H to 0.

I am sure there are some tweaks that could be made to make it more efficient.

-Brian
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: RAM consuming

Post by ~Faradey~ »

i see now, things gets more clearly now. Thank you for quick and extensive answer :)
poiru
Developer
Posts: 2873
Joined: April 17th, 2009, 12:18 pm

Re: RAM consuming

Post by poiru »

~Faradey~ wrote:I wonder why Rainmeter not removes unnecessary pages from the working set (of Rainmeter.exe process)...
Are you talking about manually forcing memory to be paged out to disk (e.g. with SetProcessWorkingSetSize)? If so, we don't do it because it is bad practice. If you have free memory available, there is absolutely no reason to page out inactive memory from RAM to disk. The disk is much slower than RAM and, consequently, accessing paged out memory entails a significant overhead.

In other words, while it may seem that you are using less memory, you most likely are wasting CPU cycles to access the paged out memory that could've been in RAM the entire time. When there is actual memory pressure, the (presumably smart) Windows memory manager will determine the best way to regain the required amount of RAM (e.g. by paging out inactive pages from some applications to disk).
User avatar
lysy1993lbn
Posts: 295
Joined: July 25th, 2011, 9:53 am
Location: Lublin, Poland

Re: RAM consuming

Post by lysy1993lbn »

Not used RAM = Wasted RAM

I don't know why a lot people cares about lowest usage of RAM.
You shouldn't worry about that, it's being used in good purposes..
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons
User avatar
~Faradey~
Posts: 366
Joined: November 12th, 2009, 4:47 pm
Location: Ukraine

Re: RAM consuming

Post by ~Faradey~ »

poiru wrote: Are you talking about manually forcing memory to be paged out to disk (e.g. with SetProcessWorkingSetSize)?
No) Absolutelly not) i understand difference between paging to disc and to RAM (i believe that is why RAM was actually created). I was talking about paging into RAM. As i said i've noticed interesting way of allocation memory behavior. When i have some skins and some hidden meters in them, they are not loaded at start, that is how i was thinking, before Brian's answer ;). I mean that i thought that loaded resources are actually for visible meters, but in real hidden meter has W and H = 0. And now i understand why when some meter become visible memory consuming increases and then after it become hidden, memory is not decreases. It makes sense when talking about animation. So i agree with current statements of things)

and for the record: just to make some sure you understand me, i was using psapi.dll and EmptyWorkingSet
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682606(v=vs.85).aspx
, but as i said now i understand why it is not practical for Rainmeter...

lysy1993lbn wrote:Not used RAM = Wasted RAM

I don't know why a lot people cares about lowest usage of RAM.
You shouldn't worry about that, it's being used in good purposes..
Ah) i don't, believe me i don't, as i wrote at my first post, i'm just wondering how thing are working, but other people do care about it...but this is not the reason i've post this question, no) i just know that some sort of comment may be occurred here or on some other forums (place) and here we (skiners, users and just peaople) have the answer :)
But if things may be better and work better....then why not?)