Page 1 of 1

Question about Vista and RAM use

Posted: 2009-06-15 11:34pm
by Pablo Sanchez
I bought a new computer a while ago and it came with Vista, which I've gotten used to, but there is an issue which I'd like to have clarified by somebody who knows such things. One of the standard desktop "gadgets" is a meter which shows the current usage of CPU and RAM. Immediately after I turn the computer on and the startup process finishes, the percentage of RAM in use while the computer is "idle" (that is, not running any intensive program) usually stays around 24% or so, but the longer I leave the computer running the higher this climbs, to a maximum of like 36-38%. I googled this and apparently there are processes in Vista that account for this kind of thing, but I'm just wondering whether this is a concern and could actually affect performance. Subjectively, resource-intensive games like Far Cry 2 seem to run noticeable better right after I boot the computer, when RAM usage at idle is lower. Is this actually the case?

Re: Question about Vista and RAM use

Posted: 2009-06-15 11:45pm
by Xon
Vista pre-loads applications & data you commonly use at a given time into memory.

Open task manager and select the performance tab, this is much better information than simply looking at the percentage of physical memory used.

For example; my computer is reading "6540 MB" cached and 6 MB free with a physical memory usage of 31% (I have 8gb of ram). Ideally, the Free value should be as close to zero as posible, that means the OS is caching as much as it can. Cached memory can be reclaimed effectively instantly if actually needed.

Really you only need to worry when the physical memory usage starts hitting +90% and you start getting thrashing when doing things often.

Re: Question about Vista and RAM use

Posted: 2009-06-16 12:09am
by Resinence
Even better, you can use the "resource monitor" that they introduced in Vista, it will show you what and where the memory is going, how much of it is cache and how much of it is shared.

Re: Question about Vista and RAM use

Posted: 2009-06-16 12:14am
by Stark
This is just one of those legacy things; people got used to 'reducing memory usage' and 'omg memory usage is bad', when in Vista it's actually a good thing (more or less).

Re: Question about Vista and RAM use

Posted: 2009-06-16 12:39am
by Ryan Thunder
My guess is that its garbage collection, which doesn't try to reduce memory useage until more is needed.

Re: Question about Vista and RAM use

Posted: 2009-06-16 05:32am
by Steel
Ryan Thunder wrote:My guess is that its garbage collection, which doesn't try to reduce memory useage until more is needed.
No, I think as others have said that as the OS can instantly clear out anything it has cached it preloads anything it thinks you might need so that things load faster. If you end up not opening anything it picked then its no slower, but if it did get something right then it'll load faster.

I was a bit annoyed when I first saw vista that it seemed to be hogging so much of my ram, but the fact is that its actually using it rather than just wasting it sitting idle is an improvement.

Re: Question about Vista and RAM use

Posted: 2009-06-16 06:13am
by Dominus Atheos
Empty RAM is wasted RAM. If you have 4GBs and the computer is only using 2GBs, you might as well not have payed for 4GBs.

Re: Question about Vista and RAM use

Posted: 2009-06-16 11:38am
by phongn
Ryan Thunder wrote:My guess is that its garbage collection, which doesn't try to reduce memory useage until more is needed.
What does GC have to do with anything?

Re: Question about Vista and RAM use

Posted: 2009-06-16 04:07pm
by Pablo Sanchez
Dominus Atheos wrote:Empty RAM is wasted RAM. If you have 4GBs and the computer is only using 2GBs, you might as well not have payed for 4GBs.
Yeah, because the most RAM intensive thing I run is my desktop.

Re: Question about Vista and RAM use

Posted: 2009-06-16 04:27pm
by Ryan Thunder
phongn wrote:
Ryan Thunder wrote:My guess is that its garbage collection, which doesn't try to reduce memory useage until more is needed.
What does GC have to do with anything?
Instead of disposing of unused memory as soon as it was no longer needed, garbage collection does not dispose of any used memory at all until more is needed for whatever the program is trying to do. This is important to consider when you're looking at how much RAM is presently being used, because you could almost fill it with things that aren't actually being used at the moment and then have a bunch of it clear out all of a sudden because it needed a few megabytes more for something else.

Re: Question about Vista and RAM use

Posted: 2009-06-16 04:31pm
by phongn
Ryan Thunder wrote:Instead of disposing of unused memory as soon as it was no longer needed, garbage collection does not dispose of any used memory at all until more is needed for whatever the program is trying to do. This is important to consider when you're looking at how much RAM is presently being used, because you could almost fill it with things that aren't actually being used at the moment and then have a bunch of it clear out all of a sudden because it needed a few megabytes more for something else.
Operating systems (in general) do not garbage collect.
Pablo Sanchez wrote:
Dominus Atheos wrote:Empty RAM is wasted RAM. If you have 4GBs and the computer is only using 2GBs, you might as well not have payed for 4GBs.
Yeah, because the most RAM intensive thing I run is my desktop.
I can't tell if you're being sarcastic or not - but DA is quite right here. An OS should be using all of the RAM it can at any instant (generally for cache) and then the moment you want to run something else, it'll overwrite said cache with the software you're actually using.

Re: Question about Vista and RAM use

Posted: 2009-06-16 04:40pm
by Ryan Thunder
phongn wrote:Operating systems (in general) do not garbage collect.
Oh? I didn't know that.

Even so, I wasn't thinking of the OS so much as whatever he had running in it.

Re: Question about Vista and RAM use

Posted: 2009-06-16 05:25pm
by Pablo Sanchez
phongn wrote:I can't tell if you're being sarcastic or not - but DA is quite right here. An OS should be using all of the RAM it can at any instant (generally for cache) and then the moment you want to run something else, it'll overwrite said cache with the software you're actually using.
So if I regularly run something (like gaming) that uses a lot of RAM, then Vista is caching that as well, and still ending up with less than 40% used. So I do have a large amount of excess RAM. The computer I bought came with six gigs of RAM, which I suppose really is excessive for gaming and will be for a couple years to come, but the other person who uses the computer likes to play around with video editing, so I thought it might be useful for that, if not for what I use it for.

Re: Question about Vista and RAM use

Posted: 2009-06-16 05:35pm
by Starglider
Ryan Thunder wrote:
phongn wrote:Operating systems (in general) do not garbage collect.
Oh? I didn't know that.
Even so, I wasn't thinking of the OS so much as whatever he had running in it.
Garbage collection does not work like that; except for in a few exotic research OSes, it's layered on top of normal memory management. When it starts up a program requests a certain amount of memory from the OS, say 100 megabytes. Initially this space is unused, but it still shows up as 'used' in your memory meter, because it's been reserved for the use of that specific program. As the program loads and creates data, the space is filled up. When the program needs more memory but there is nothing left in its already allocated block, it requests another chunk (say another 50 megabytes) from the OS. In runtime systems that use garbage collection, a GC pass is made right before asking for more memory from the OS, to try and free up some more space in the program's currently allocated memory and avoid requesting more.

I'd note that your premise is incorrect anyway, because basically all GC systems make regular GC passes even when there is plenty of heap space remaining. This is to avoid stalling the program with a huge burst of GC activity when the memory runs out, and in some systems (e.g. the Sun Java VM) to optimise memory layout for higher performance.

Non-GC sytems suffer from at least as much if not more wasted space due to fragmentation and the fact that without active compaction it's difficult to return space to the OS except in the case of specially allocated buffers. There's no way to know how much of the memory a program is shown as using is actually using without breaking out (language-specific) profiling tools.