Working of virtual memory

i just have a doubt that on which disk drive is virtual memory is implemented.
that is when proper space is not found on the RAM then from which portion of hard disk is the paging file made.

is the paging file made initially only on hard disk or when virtual memory manager realizes that space is less on RAM that time it realizes that it should make the paging file of that application which cnt fit in RAM.

plz explain how the processing takes place .

Replies

  • Abhishek Rawal
    Abhishek Rawal
    In Linux, special space is allocated from Hard drive during installation of OS, called as Swap Area. As Swap area is allocated from hd, it has slower access to that of physical memory.

    What happens is, when physical memory becomes full, the system will need more memory, so all the inactive pages are moved from physical memory to swap area & thus space is obtained in physical memory. We usually allot double swap area to that of physical memory (RAM) i.e for 2GB RAM, we allot 4096 MB of Swap area.

    This is for Linux based system. I dont know if there's another mechanism for OS X or Windows. Honestly, I don't really care for latter mentioned systems ๐Ÿ˜‰
  • radha gogia
    radha gogia
    Abhishek Rawal
    In Linux, special space is allocated from Hard drive during installation of OS, called as Swap Area. As Swap area is allocated from hd, it has slower access to that of physical memory.

    What happens is, when physical memory becomes full, the system will need more memory, so all the inactive pages are moved from physical memory to swap area & thus space is obtained in physical memory. We usually allot double swap area to that of physical memory (RAM) i.e for 2GB RAM, we allot 4096 MB of Swap area.

    This is for Linux based system. I dont know if there's another mechanism for OS X or Windows. Honestly, I don't really care for latter mentioned systems ๐Ÿ˜‰
    thankss,i want to knw the litlle depth,thats why i asked
  • Abhishek Rawal
    Abhishek Rawal
    radha gogia
    thankss,i want to knw the litlle depth,thats why i asked
    Didn't I answered everything you asked ? If not, then tell me what you want to know "in depth". If I know, then I will surely answer, if not then some other CEan who knows about it will answer.
    So please elaborate, what you want to know in depth ! ?
  • Anoop Kumar
    Anoop Kumar
    Paging always happen between cache memory (processor's one) and between RAM. virtual memory and swap area are the spaces in HDD which acts like RAM (That's why it is named as virtual memory).
    Now when OS realizes that there are some more stuff need to be in RAM more than space left, OS simply put the less used RAM data in HDD's virtual/swap memory. This is totally depends upon how exactly particular OS works for swamping between RAM and HDD.
    If you are asking that if OS puts the swap files on HDD initially then you are implying that there is always a clone of RAM on HDD. Do you think, it a good way of managing memory?
  • radha gogia
    radha gogia
    Abhishek Rawal
    Didn't I answered everything you asked ? If not, then tell me what you want to know "in depth". If I know, then I will surely answer, if not then some other CEan who knows about it will answer.
    So please elaborate, what you want to know in depth ! ?
    i just want to ask that is the page file always initially made in the hard disk irrespective of whether a program is running out of space or not.
    And if not then,when is the page file made in hard disk and who makes it.and if i increase the size of virtual memory does the speed of computer incresase or decreases.and if we have to actually implement it using virtual memory then all the drives we have,through it only we'll be able to implement it,then is it that we can have virtual memory in each drive and what if any time the space of even virtual memory becomes less.
  • radha gogia
    radha gogia
    Anoop Kumar
    Paging always happen between cache memory (processor's one) and between RAM. virtual memory and swap area are the spaces in HDD which acts like RAM (That's why it is named as virtual memory).
    Now when OS realizes that there are some more stuff need to be in RAM more than space left, OS simply put the less used RAM data in HDD's virtual/swap memory. This is totally depends upon how exactly particular OS works for swamping between RAM and HDD.
    If you are asking that if OS puts the swap files on HDD initially then you are implying that there is always a clone of RAM on HDD. Do you think, it a good way of managing memory?
    sir then actually when is the page file maintained inside hdd ,does each program has its own page file in hard disk.and if after swapping some un-used programs also there is no space in ram,then what about the program running.
    if i have a 16 gb software and ram size only 2gb ,then its obvious that even after swapping out some unused programs from the ram,still enough space cannot be accomadated ,then how will that program run in ram.
  • Abhishek Rawal
    Abhishek Rawal
    radha gogia
    i just want to ask that is the page file always initially made in the hard disk irrespective of whether a program is running out of space or not.
    I don't think so. Proof :
    snapshot4โ€‹
    You can notice that swap is zero at this moment. So, unless my process memory don't reach >= 2 GB, the least used pages of memory of RAM won't be moved to virtual memory. If page files are moved before system runs low on RAM, then actually it's not good because when we restore application from virtual memory it usually takes a little longer than that of RAM, eventually making system slow.

    radha gogia
    when is the page file made in hard disk and who makes it.
    Like #-Link-Snipped-# mentioned Page files are always made. It's just when your physical memory (RAM) is about to get full, the least used pages of memory is moved to Swap area. And, as swap area is part of HDD, retrieving takes more response time.
    For eg : You are currently running multiple programs, on one side one program & on other side you're doing some other heavy work. While you're not using one program for long period of time, the system will mark it as least used pages of memory & will move those pages to virtual memory. So when you again try to access that program, it will take more time than usual to retrieve those pages. You'll feel that system is slowed down a bit.

    radha gogia
    if i increase the size of virtual memory does the speed of computer incresase or decreases.
    That totally depends on physical memory you have & what type of program are you running. Now a days computers are equipped with 6 GB to 16 GB RAM, they usually don't require Swap area. You'll see that in system with very high RAM memory, the swap area will always remain idle i.e null. Hence in Linux system we never 'mkswap' for system with high RAM. Because it's just wastage of hard-disk memory.

    Only if you're running heavy application simultaneously that are capable to consume 6 GB to 8Gb then only swap is needed. Old systems usually require Swap area due to low RAM memory & modern applications takes huge amount of resources.

    So, in short, Speed of computer doesn't depend on size of virtual memory. It usually depends on available physical memory & the application used by an user.
  • radha gogia
    radha gogia
    Abhishek Rawal
    I don't think so. Proof :
    snapshot4โ€‹
    You can notice that swap is zero at this moment. So, unless my process memory don't reach >= 2 GB, the least used pages of memory of RAM won't be moved to virtual memory. If page files are moved before system runs low on RAM, then actually it's not good because when we restore application from virtual memory it usually takes a little longer than that of RAM, eventually making system slow.


    Like #-Link-Snipped-# mentioned Page files are always made. It's just when your physical memory (RAM) is about to get full, the least used pages of memory is moved to Swap area. And, as swap area is part of HDD, retrieving takes more response time.
    For eg : You are currently running multiple programs, on one side one program & on other side you're doing some other heavy work. While you're not using one program for long period of time, the system will mark it as least used pages of memory & will move those pages to virtual memory. So when you again try to access that program, it will take more time than usual to retrieve those pages. You'll feel that system is slowed down a bit.


    That totally depends on physical memory you have & what type of program are you running. Now a days computers are equipped with 6 GB to 16 GB RAM, they usually don't require Swap area. You'll see that in system with very high RAM memory, the swap area will always remain idle i.e null. Hence in Linux system we never 'mkswap' for system with high RAM. Because it's just wastage of hard-disk memory.

    Only if you're running heavy application simultaneously that are capable to consume 6 GB to 8Gb then only swap is needed. Old systems usually require Swap area due to low RAM memory & modern applications takes huge amount of resources.

    So, in short, Speed of computer doesn't depend on size of virtual memory. It usually depends on available physical memory & the application used by an user.
    thanku so much sir fr ur kind response
  • radha gogia
    radha gogia
    Abhishek Rawal
    I don't think so. Proof :
    snapshot4โ€‹
    You can notice that swap is zero at this moment. So, unless my process memory don't reach >= 2 GB, the least used pages of memory of RAM won't be moved to virtual memory. If page files are moved before system runs low on RAM, then actually it's not good because when we restore application from virtual memory it usually takes a little longer than that of RAM, eventually making system slow.


    Like #-Link-Snipped-# mentioned Page files are always made. It's just when your physical memory (RAM) is about to get full, the least used pages of memory is moved to Swap area. And, as swap area is part of HDD, retrieving takes more response time.
    For eg : You are currently running multiple programs, on one side one program & on other side you're doing some other heavy work. While you're not using one program for long period of time, the system will mark it as least used pages of memory & will move those pages to virtual memory. So when you again try to access that program, it will take more time than usual to retrieve those pages. You'll feel that system is slowed down a bit.


    That totally depends on physical memory you have & what type of program are you running. Now a days computers are equipped with 6 GB to 16 GB RAM, they usually don't require Swap area. You'll see that in system with very high RAM memory, the swap area will always remain idle i.e null. Hence in Linux system we never 'mkswap' for system with high RAM. Because it's just wastage of hard-disk memory.

    Only if you're running heavy application simultaneously that are capable to consume 6 GB to 8Gb then only swap is needed. Old systems usually require Swap area due to low RAM memory & modern applications takes huge amount of resources.

    So, in short, Speed of computer doesn't depend on size of virtual memory. It usually depends on available physical memory & the application used by an user.
    thanku so much sir fr ur kind response,but just want to ask that
    Abhishek Rawal
    I don't think so. Proof :
    snapshot4โ€‹
    You can notice that swap is zero at this moment. So, unless my process memory don't reach >= 2 GB, the least used pages of memory of RAM won't be moved to virtual memory. If page files are moved before system runs low on RAM, then actually it's not good because when we restore application from virtual memory it usually takes a little longer than that of RAM, eventually making system slow.


    Like #-Link-Snipped-# mentioned Page files are always made. It's just when your physical memory (RAM) is about to get full, the least used pages of memory is moved to Swap area. And, as swap area is part of HDD, retrieving takes more response time.
    For eg : You are currently running multiple programs, on one side one program & on other side you're doing some other heavy work. While you're not using one program for long period of time, the system will mark it as least used pages of memory & will move those pages to virtual memory. So when you again try to access that program, it will take more time than usual to retrieve those pages. You'll feel that system is slowed down a bit.


    That totally depends on physical memory you have & what type of program are you running. Now a days computers are equipped with 6 GB to 16 GB RAM, they usually don't require Swap area. You'll see that in system with very high RAM memory, the swap area will always remain idle i.e null. Hence in Linux system we never 'mkswap' for system with high RAM. Because it's just wastage of hard-disk memory.

    Only if you're running heavy application simultaneously that are capable to consume 6 GB to 8Gb then only swap is needed. Old systems usually require Swap area due to low RAM memory & modern applications takes huge amount of resources.

    So, in short, Speed of computer doesn't depend on size of virtual memory. It usually depends on available physical memory & the application used by an user.
    thanku sir,but is there any issue that we can increase the virtual memory size depending on the size of RAM ,that is there any relationship between RAM size and virtual memory size
  • Abhishek Rawal
    Abhishek Rawal
    radha gogia
    is there any issue that we can increase the virtual memory size depending on the size of RAM ,that is there any relationship between RAM size and virtual memory size
    In Linux we have general criteria of
    If mem<2
      swap=mem*2
    else
      swap=mem+2
    However, For very high RAM size (> 16 GB) you can keep swap size equal to memory size (i.e mem = swap) or even 75% of that of total RAM size, depending on your RAM size & task you're going to perform.
  • radha gogia
    radha gogia
    Abhishek Rawal
    In Linux we have general criteria of
    If mem<2
      swap=mem*2
    else
      swap=mem+2
    However, For very high RAM size (> 16 GB) you can keep swap size equal to memory size (i.e mem = swap) or even 75% of that of total RAM size, depending on your RAM size & task you're going to perform.
    yes sir,but why is it so that we are making the virtual memory 1.5 times the physical memory size,we need to just swap pages from virtual memory to RAM ,so is it that if its size would be more than access time and transfer time from RAM to virtual memory would increse
  • Abhishek Rawal
    Abhishek Rawal
    First of all, drop the 'Sir' please. It makes me feel old. ๐Ÿ˜€
    radha gogia
    yes sir,but why is it so that we are making the virtual memory 1.5 times the physical memory size,we need to just swap pages from virtual memory to RAM ,so is it that if its size would be more than access time and transfer time from RAM to virtual memory would increse
    Now, I don't think there is any relation between size of virtual memory & access time. Access time is totally dependent on what type of HDD you're using. SSDs will have faster response to that of traditional magnetic platter hard-disks.

    2x times of swap area to that of RAM size is the old rule which sadly most are still following. Memory management have became smarter than before when swap was introduced. There is no mandatory rule to allot 1.5x or 2x times RAM memory to Swap. I never allot 2x Swap, I always keep it equal i.e for 2GB RAM, 2 GB of Swap.
  • radha gogia
    radha gogia
    Abhishek Rawal
    First of all, drop the 'Sir' please. It makes me feel old. ๐Ÿ˜€

    Now, I don't think there is any relation between size of virtual memory & access time. Access time is totally dependent on what type of HDD you're using. SSDs will have faster response to that of traditional magnetic platter hard-disks.

    2x times of swap area to that of RAM size is the old rule which sadly most are still following. Memory management have became smarter than before when swap was introduced. There is no mandatory rule to allot 1.5x or 2x times RAM memory to Swap. I never allot 2x Swap, I always keep it equal i.e for 2GB RAM, 2 GB of Swap.
    so actually u want to say that if virtual memory has more size than RAM ,it wont create any issue,but when we 'll increase the size then it has to refer to more memory locations ,as it is in the case of CACHE ,that its size is kept less so that cpu can eventually access it in less time.so i just am still confused that can i increase the size of virtual memory to any extent(confinning to a particular drive) or it has to be limited.

    also if its size i decrease manually,then will it try to take space from another drive and if i have no partitions then what will happen? plz this time just clear it becoz i am totally confused with the fact that the logical adress which the cpu generates is belonging to which disk drive becoz first it will be mapped to physical address,then page will be brought from hard disk,so from which drive will it bring and who is responsible for prompting cpu to generate addresses when cpu scheduler brings the processes from waiting queue to ready queue
  • Anoop Kumar
    Anoop Kumar
    radha gogia
    so actually u want to say that if virtual memory has more size than RAM ,it wont create any issue,but when we 'll increase the size then it has to refer to more memory locations ,as it is in the case of CACHE ,that its size is kept less so that cpu can eventually access it in less time.
    You got totally wrong concept here. Cache memory is small not because it can be accessed faster but very costly that's why it is low in size.
    If is possible, cost wise, manufacturer will make GB's of cache memory we will never need RAM or hdd swap.
    If you have patience, go through this paper.
    PDF
  • radha gogia
    radha gogia
    Anoop Kumar
    You got totally wrong concept here. Cache memory is small not because it can be accessed faster but very costly that's why it is low in size.
    If is possible, cost wise, manufacturer will make GB's of cache memory we will never need RAM or hdd swap.
    If you have patience, go through this paper.
    PDF
    i just knw that cache is used to increase the access speed of the processor so it has small size so that it can have only frequently stored data and that is why it has less memory locations.
    this concept only i am trying to attach it to virtual memory if has more size than speed will decrease a bit by bringing data from it becoz more locations so more access time
  • Anoop Kumar
    Anoop Kumar
    radha gogia
    i just knw that cache is used to increase the access speed of the processor so it has small size so that it can have only frequently stored data and that is why it has less memory locations.
    So you are now clear that larger cache memory is good for computing?
    The rule applies to Cache and RAM same rule applies between RAM and swap
    One more question you asked
    if i have a 16 gb software and ram size only 2gb ,then its obvious that even after swapping out some unused programs from the ram,still enough space cannot be accomadated ,then how will that program run in ram.
    A software of 16 gb, doesn't mean that it will be loaded all at once in RAM. They have addition files, modules which will be loaded when they required.
    Think about that if you are playing Blue-Ray disc of 8GB movie, does all the 8GB loads in RAM at once?
  • Abhishek Rawal
    Abhishek Rawal
    The mechanism of swap cache is not similar to that of hardware cache and/or buffer cache. Afaik swap caches contains information which allows the system to find the correct page & to take required steps if pages are modified or not.

    How it helps to improve the access time ? I am not aware of!
  • radha gogia
    radha gogia
    Abhishek Rawal
    The mechanism of swap cache is not similar to that of hardware cache and/or buffer cache. Afaik swap caches contains information which allows the system to find the correct page & to take required steps if pages are modified or not.

    How it helps to improve the access time ? I am not aware of!
    it increases the access time becoz searching time of pages inside cache is less becoz of limited no of memory locations
  • Abhishek Rawal
    Abhishek Rawal
    radha gogia
    it increases the access time becoz searching time of pages inside cache is less becoz of limited no of memory locations
    Elaborate please.
  • radha gogia
    radha gogia
    Abhishek Rawal
    Elaborate please.
    its a simple concept of data structures only that the algorithm applied to search any piece of data in a data structure is made considering the entire size of that data structre ,ans so the searching time,so cache is made small so as to decrease the access or searching time of a particular page
  • Anoop Kumar
    Anoop Kumar
    Ok, please confirm what you thought of this:
    A processor with 2Mb cache works better than 16Mb cache. Right or wrong?
  • Anoop Kumar
    Anoop Kumar
    You got wrong concept that less cache memory means higher performance.
    Hypothetically if I can have 8GB cache memory,then why would I need RAM?
    Please read Operating System concepts how exactly it works, do not make your concept from blog links.
    Even if you didn't have study OS yet, goto this new link and tell me why 20mb cache processor costs almost double to 15MB cache. And why new processor are adding more cache.
    #-Link-Snipped-#
  • radha gogia
    radha gogia
    Anoop Kumar
    You got wrong concept that less cache memory means higher performance.
    Hypothetically if I can have 8GB cache memory,then why would I need RAM?
    Please read Operating System concepts how exactly it works, do not make your concept from blog links.
    Even if you didn't have study OS yet, goto this new link and tell me why 20mb cache processor costs almost double to 15MB cache. And why new processor are adding more cache.
    #-Link-Snipped-#
    sir i am seriously now getting confused,about the size of cache and its performance measure ,if u can explain concisely,it would be very kind of you
  • Anoop Kumar
    Anoop Kumar
    I am not going any depth like swap address area in RAM or what so ever.
    The speed of cache vs ram is around 1000 times and it's same for RAM vs HDD.
    Find any processor/cache memory diagram you can see when processor needs any data, tries to find in cache and if not found then strike for the RAM.
    If if cache memory would be cheaper, everything would be loaded into cache itself.
    For
    performance measure of system in terms of RAM size, if you only do browsing and word processing you will not need 16 GB of RAM. As all running program may never need more than 3-4 GB of RAM.
  • Vishal Sharma
    Vishal Sharma
    Books are friends. You should first read the concept, if you still face doubts then post it on the forum. It'll be better if people clarify your doubts instead of teaching the complete concept on a thread. Hope that makes sense.
  • radha gogia
    radha gogia
    Anoop Kumar
    I am not going any depth like swap address area in RAM or what so ever.
    The speed of cache vs ram is around 1000 times and it's same for RAM vs HDD.
    Find any processor/cache memory diagram you can see when processor needs any data, tries to find in cache and if not found then strike for the RAM.
    If if cache memory would be cheaper, everything would be loaded into cache itself.
    For
    performance measure of system in terms of RAM size, if you only do browsing and word processing you will not need 16 GB of RAM. As all running program may never need more than 3-4 GB of RAM.
    ya sir ,actually there was some misconceptions which were creating confusions ,nw i am through with it,thanku so much

You are reading an archived discussion.

Related Posts

hello. i just saw some of the discussions on this site and hoped that i could get some help from here..!! i am currently pursuing my b tech 2nd year...
Here is the problem i face Currently, I'm using Windows 8(Genuine), Make & Model HP Pavilion 15 Notebook & PC 15- E015TX, The problem is while connecting over public wifi(wireless...
hi, i am pradeep. i am b.tech (ece) 2014 passout. i want to start small scale business related to electronics field. so i request to please give me some idea...
i installed the quick heal total security cracked version ,but when i visited one site,the icon that comes in the toolbar below just dis-appeared,may i know now what to do...
i just want to ask that who is responsible for bringing the programs from hard disk to RAM and after coming to RAM it becomes a process then where is...