Do i need virtual memory enabled with 4gig of ram?

I'm sorry, but i am going to have to disagree. yes if the op had only little ram i would agree a large page file. but at the 4gb a big page isn't needed. I guess, you could test it having say, 1gb page. and a 4gb page. and seeing which one works better for you.
 
NathanE said:
Yup, set it to 4GB.

Virtual memory isn't an overflow carpark, it's meant to be a slightly dirty mirror image of what's in physical memory.

I was under the impression that virtual memory was used when system memory was full. When a new program requests memory, if there is non available then the kernel will move an idle program from system memory into the page file. I am interested to know if that is an incorrect impression.
 
Theguy said:
I'm sorry, but i am going to have to disagree. yes if the op had only little ram i would agree a large page file. but at the 4gb a big page isn't needed. I guess, you could test it having say, 1gb page. and a 4gb page. and seeing which one works better for you.

You don't understand what the page file is. Google and find out actually what the page file and virtual memory is for.

I had a rubbish explanation all typed out but the post below this is much better.
 
Last edited:
thats what most folks think saffyre - and to an extent that does happen.

Virtual Ram is basically back up for the main memory, i dont mean for space i mean for instructions. for certain instructions the main memory doesnt need to hold it resident so it gets dropped into the VM. The main Memory and VM get swapped a lot - hence the term Swap File, its where the main memory has grabbed all relevant info it swaps it into VM, this leaves it in "Memory" and therefore can be addressed but doesnt take up physical ram - which will be doing more immediate things.

as an example if you have 2 applications running - both memory hogs:
example setup - system with 2gb physical memory and 2gb(or more) VM

you have both running -
Photoshop is using 1.5gb memory and your doing usual photoshop stuff, then you switch to Maya, which needs a few hundred mb of ram to run.

Now if Maya needs 800mb to run .. obviously some of photoshop needs to be dumped into VM, photoshop is dumped into vm not Maya because Maya is the current application (most apps get put partially into VM even if they are current) so your now using 2.3gb ram .. Note you wont be using 2gb physical and 300mb of VM at this time.

Whats more likely is over time, more of photoshop will be pushed into vm as windows feels its no longer relevant to have instant speed access to it. (which is where readyboost on vista comes in).

So photoshop is now using 500mb of physical 1gb of VM
and Maya is using 800mb of Physical. Yes Not all physical is now being used - additional physical memory has been freed to help out Maya which is the current app and for any additional processes that are needed.

VM is address space, used originaly to overcome OS bit limitations. These days has been utilized and intergrated further for better uses. It does not just backup physical ram Nor does it only use it after physical ram has run out.

VM is used all the time to allow multiple applications and windows to better manage what physical memory is being used and for what. why waste physical memory on something thats not been accessed for a few hours - especially when a newly opened application could utilize the full speed of the physical ram.

Excuse the slightly random explanation... i think it made rough sense.

On a last note.. if you turn OFF Vm in windows and have everything load into physical only youll have serious limitations to what will run and how much memory youll use. Think of how many windows processes which are running when you boot dont "need" to be accessed at lightning speed every second of the day. with VM off.. all these processes WILL be wasting physical ram, unlike with VM they could be sitting in the background (still being allowed to run and be accessed because thier in memory addressed space) using half or less of the physical memory they would need - remember as soon as the process or app is needed.. itll be SWAPPED back onto physical from the Swap file (pagefile) and run as normal.

Cheers
ROfu
 
Last edited:
Theguy said:
I'm sorry, but i am going to have to disagree. yes if the op had only little ram i would agree a large page file. but at the 4gb a big page isn't needed. I guess, you could test it having say, 1gb page. and a 4gb page. and seeing which one works better for you.
I can give you the answer right now :) the 4GB page file will perform better.

Even when you turn the page file off in Windows it will make a temporary one anyway. There is no way to run Windows with paging completely turned off. In fact most modern virtual memory based OSes are the same.
 
saffyre said:
I was under the impression that virtual memory was used when system memory was full. When a new program requests memory, if there is non available then the kernel will move an idle program from system memory into the page file. I am interested to know if that is an incorrect impression.
It's easy to get that impression but unfortunately it could not be further from the truth. Virtual memory is simply a way to give each running application a full 32 (or 64) bit address space. This means each application "thinks" it has a whole memory allocation to itself. In reality though it is just the OS tricking the software into thinking this by presenting a virtual memory address space.

Internally the kernel's memory manager will perform page swapping (swapping pages of memory into and out of physical memory between the page file). When this occurs it is caused a page fault. It's not really a fault though, it is completely normal operation... when you start getting hundreds per second though that's when you need to start to worry.

The kernel decides which pages to keep in memory and which ones to page out. It uses hundreds of variables to decide this... such as whether the application is a foreground or background window, how often it is used, whether it has been recently minimised etc.
 
Thats pretty much the idea i had of virtual memory. I imagine there a many different techniques used by different OS to optimize the use of VM. Im not sure about XP but i find that my Gentoo system rarely uses its swap file if ever.

Edit: I have studied the unix VM system, i guess my initial description was a bit lacking.
 
Last edited:
Your previous impression of VM was completely wrong though. It isn't a case of:
1. program requests a page of memory
2. kernel checks if any physical memory free
3. if yes, allocates it and gives program pointer
4. if no, allocates some space in page file and gives program pointer.

That's completely wrong and no modern operating systems work in this way.

The correct flow is more like:
1. program requests page of memory
2. kernel looks down virtual memory address space for a free page.
3. kernel determines if there is a free frame in physical memory
4. if yes, kernel changes VM page flag to "physical memory" and updates pointer
5. if no, kernel changes VM page flag to "page file" and updates pointer.
Note: Vista has a third type of flag called "ReadyBoost" which indicates the page is also available from a USB memory stick. If this flag is set Vista will always first attempt to read the page from there first because seek time is 0ms.
6. returns virtual memory page pointer to program.

Pages of memory are allocated on a 4KB granularity. And each page has a number of statistics recorded against it. Such as read and write frequency, age, page fault delta etc. These are essential variables that the memory manager in the kernel uses to determine which pages of memory can be swapped out to the page file if physical memory is getting tight or if that page of memory is very very idle.

XP has a very conservative memory manager. Vista, like many Linux distros, has a more aggressive memory manager. It tries much harder to keep pages in main memory.
 
Last edited:
without randomly throwing a spanner in the works isnt VM in its base form just additional memory addressing space?.

Therefore its an extension to physical memory in its base form. i guess its the memory management of the OS which actually dictates whether the physical or Virtual memory is used and how its swapped.

edit - wouldnt that mean without a memory management system on the OS .. vm would just be used once physical memory was depleted

Cheers
ROfu
 
actually i think im talking **** as VM wouldnt be available without a memory management system - ignore previous post :(

Cheers
ROfu
 
does it really matter leaving a pagefile on, unless you have something stupid like a 20gb hdd then what are you worried about space for??
 
I think his original question was do to with Speed, and if he turned off pagefile would the system force applications to run on physical memory .. and would be therefore faster. I dontthink its a matter of space available (could be wrong ;))

as everyone has stated tho.. leave it on and if your on windows XP or Vista just use system managed - then itll use what it needs when it needs it.

Cheers
ROfu
 
Its not likely that any OS would start a new Process or allocate a running process memory in the page file? After all no process can run when its memory resides upon the page file on disc, the memory needs to be in main memory before the cpu can access it.

As stated it is likely the OS will always keep some memory free for new apps, and in the case that there is no free memory i would imagine it would move some other pages from a process it determines from main memory onto the page file then allocate main memory to the new process.

Im working on a linux model of VM, this uses page tables to map virtual memory to physical memory for a given process. So for example if an idle process has one of its pages moved from main memory to page file, the page table entry is updated to link to the addess in the page file rather than main memory. This means the app can use the same virtual address each time, this is where page faults come in, as if an app requests a page that resideds on the hard disk a page fault is thrown and the os moves the page from file to main memory.

Back to the original point of the necessity of a page file for systems with large memory. I mean say i have a system with 1gb main mem and a 1gb page file. That gives me 2gb of virtually adressable memory for my system. Now say i have a system with 4gb of main memory and no page file i now have 4gb of virtually addressable memory, although as there is no page file its really all just system memory. The main reason i can think of for the necessity of a page file is that it is possible for the OS to allocate more page file space if it needs it, and there is available space. This is obv not poss on a system with no page file. Thoughts?
 
i guess it would depend on what your using the system for - i agree that 4gb of physical memory is obviously better than 1gb physical and 1gb of vm.
But wouldnt the OS automatically try and free up physical memory to swap if its not being accessed but still loaded. irrelevant to how much memory you have.

as to your first statement
"Its not likely that any OS would start a new Process or allocate a running process memory in the page file? After all no process can run when its memory resides upon the page file on disc, the memory needs to be in main memory before the cpu can access it."

any app that after its initial launch resides in the background doing nothing - can happily sit in VM it will still use some physical or it wouldnt be able to run at all, but its main bulk (depending on the app) can and will spend most of its time im VM in windows (linux manages memory far better on 32bit OS, but not as well on 64bit from personal experience).

Cheers
ROfu
 
saffyre said:
Its not likely that any OS would start a new Process or allocate a running process memory in the page file? After all no process can run when its memory resides upon the page file on disc, the memory needs to be in main memory before the cpu can access it.
That's absolutely correct. The CPU cannot work with addresses in the page file. It can however work with virtual memory addresses. If the CPU attempts to access a page of memory that is currently stored in the page file then it will raise a hardware interrupt (called a "page fault") which will be intercepted by the kernel's memory manager. The memory manager then tries its darndest to bring this page of memory into physical memory. If need be it will page out another idle page of memory in order to do so.
As stated it is likely the OS will always keep some memory free for new apps, and in the case that there is no free memory i would imagine it would move some other pages from a process it determines from main memory onto the page file then allocate main memory to the new process.
Nope. No OS will delibrately set aside memory in some attempt to predict the future. There is a large pool of memory used by the OS called the "system cache". This is where the OS just stores recently performed I/O and other types of intermediate cache. This memory can be overwritten immediately if need be. More often than not the OS will simply take a page from the available pool - because let's face it, on 4GB of RAM there is probably going to be a rather sizable available pool of memory ;)
 
Last edited:
Simply put ideally the Os needs to be able to mirror all physical memory to page file if needed so you have 4GB of ram then you should have 4GB pagefile.

Or would you rather have a problem that the Os wanted to move 2GB of mem content to pagefile for whatever reason but could not because you only gave it 1GB pagefile & popup & say you need to close some apps.
 
Back
Top Bottom