Is virtual memory real or is it just a method to manage the memory












0















I'm not sure if virtual memory is actually a physical component, or people just refer to it as a method to optimize memory processes.










share|improve this question













migrated from electronics.stackexchange.com Dec 18 '18 at 11:42


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.











  • 2





    There are many different things often referred as "virtual memory". Please be more specific.

    – Eugene Sh.
    Dec 12 '18 at 14:50






  • 1





    en.wikipedia.org/wiki/Virtual_memory

    – Andy aka
    Dec 12 '18 at 14:57






  • 1





    Virtual memory is a concept, but for implementing it you need a very real part of the CPU circuitry called a MMU. It is a hefty thing, requiring real estate in the silicon, as it has caches, and is accessed through a dozen or two of dedicated instructions.

    – anrieff
    Dec 12 '18 at 15:00
















0















I'm not sure if virtual memory is actually a physical component, or people just refer to it as a method to optimize memory processes.










share|improve this question













migrated from electronics.stackexchange.com Dec 18 '18 at 11:42


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.











  • 2





    There are many different things often referred as "virtual memory". Please be more specific.

    – Eugene Sh.
    Dec 12 '18 at 14:50






  • 1





    en.wikipedia.org/wiki/Virtual_memory

    – Andy aka
    Dec 12 '18 at 14:57






  • 1





    Virtual memory is a concept, but for implementing it you need a very real part of the CPU circuitry called a MMU. It is a hefty thing, requiring real estate in the silicon, as it has caches, and is accessed through a dozen or two of dedicated instructions.

    – anrieff
    Dec 12 '18 at 15:00














0












0








0








I'm not sure if virtual memory is actually a physical component, or people just refer to it as a method to optimize memory processes.










share|improve this question














I'm not sure if virtual memory is actually a physical component, or people just refer to it as a method to optimize memory processes.







memory






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 12 '18 at 14:49







Thong Nguyen Thanh











migrated from electronics.stackexchange.com Dec 18 '18 at 11:42


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.






migrated from electronics.stackexchange.com Dec 18 '18 at 11:42


This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.










  • 2





    There are many different things often referred as "virtual memory". Please be more specific.

    – Eugene Sh.
    Dec 12 '18 at 14:50






  • 1





    en.wikipedia.org/wiki/Virtual_memory

    – Andy aka
    Dec 12 '18 at 14:57






  • 1





    Virtual memory is a concept, but for implementing it you need a very real part of the CPU circuitry called a MMU. It is a hefty thing, requiring real estate in the silicon, as it has caches, and is accessed through a dozen or two of dedicated instructions.

    – anrieff
    Dec 12 '18 at 15:00














  • 2





    There are many different things often referred as "virtual memory". Please be more specific.

    – Eugene Sh.
    Dec 12 '18 at 14:50






  • 1





    en.wikipedia.org/wiki/Virtual_memory

    – Andy aka
    Dec 12 '18 at 14:57






  • 1





    Virtual memory is a concept, but for implementing it you need a very real part of the CPU circuitry called a MMU. It is a hefty thing, requiring real estate in the silicon, as it has caches, and is accessed through a dozen or two of dedicated instructions.

    – anrieff
    Dec 12 '18 at 15:00








2




2





There are many different things often referred as "virtual memory". Please be more specific.

– Eugene Sh.
Dec 12 '18 at 14:50





There are many different things often referred as "virtual memory". Please be more specific.

– Eugene Sh.
Dec 12 '18 at 14:50




1




1





en.wikipedia.org/wiki/Virtual_memory

– Andy aka
Dec 12 '18 at 14:57





en.wikipedia.org/wiki/Virtual_memory

– Andy aka
Dec 12 '18 at 14:57




1




1





Virtual memory is a concept, but for implementing it you need a very real part of the CPU circuitry called a MMU. It is a hefty thing, requiring real estate in the silicon, as it has caches, and is accessed through a dozen or two of dedicated instructions.

– anrieff
Dec 12 '18 at 15:00





Virtual memory is a concept, but for implementing it you need a very real part of the CPU circuitry called a MMU. It is a hefty thing, requiring real estate in the silicon, as it has caches, and is accessed through a dozen or two of dedicated instructions.

– anrieff
Dec 12 '18 at 15:00










1 Answer
1






active

oldest

votes


















4














Virtual memory is a concept.



As anrieff says, systems which support virtual memory will have an MMU that actually handles the mapping. The processor will use virtual addresses, which may be any address in the 32 or 64 bit address space it supports. Virtual addresses aren't limited by the amount of physical memory.



As I mentioned in my comment, virtual memory does not have to map to anything. There are two sets of tables involved:




  • the MMU page tables, which may map to real physical memory or may not depending on the "present" bit. You can have pages which are not "present"; the MMU neither knows nor cares what they might contain, but they're not mapped to real physical DRAM. If you try to access one of these the system generates a page fault to the operating system.


  • the operating system keeps track of memory allocation to processes and itself, and takes responsibility for handling page faults. It can decide what to do with not-present pages while the process that accessed the memory is paused. Possible choices include:



Swap: the page is swapped out. Allocate some real DRAM and read from disk into it, then return to the process.



Memory-mapped IO: similar, but reading from a specific file.



PCI/AGP space: the request goes over the bus to e.g. a GPU rather than main memory.



Zeros: either the operating system keeps some pre-zeroed DRAM ready, or it stops to write zeros to a page before giving it to you.



Invalid: finally, it's entirely possible for the operating system to not return at all and just kill the process that asked for that page. A common example is Linux memory "overcommit": processes can request and allocate more memory than available DRAM+swap space. This is fine as long as they don't use it. If they do all use it and the system runs out of real memory, it will start killing processes to recover the system. Other crisis situations might include memory mapped IO to a file over the network which has gone away, or swap on a drive which has failed.



You can deliberately allocate an unusable page (mmap option PROT_NONE on Linux). This is occasionally useful for finding certain kinds of bug.






share|improve this answer
























  • I'm not 100% sure, but if IIRC, Linux overcommit and OOM Killer are two different things: it may be that Process A requested the page that went over the limit of physical memory + swap; then the OOM killer kicks in, but it may decide to kill a different process, Process B, and in the end a valid page is served to A ("here's the page you requested; sorry that you had to wait, we were just busy killing other customers, so that we could serve you").

    – anrieff
    Dec 12 '18 at 15:54











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385536%2fis-virtual-memory-real-or-is-it-just-a-method-to-manage-the-memory%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Virtual memory is a concept.



As anrieff says, systems which support virtual memory will have an MMU that actually handles the mapping. The processor will use virtual addresses, which may be any address in the 32 or 64 bit address space it supports. Virtual addresses aren't limited by the amount of physical memory.



As I mentioned in my comment, virtual memory does not have to map to anything. There are two sets of tables involved:




  • the MMU page tables, which may map to real physical memory or may not depending on the "present" bit. You can have pages which are not "present"; the MMU neither knows nor cares what they might contain, but they're not mapped to real physical DRAM. If you try to access one of these the system generates a page fault to the operating system.


  • the operating system keeps track of memory allocation to processes and itself, and takes responsibility for handling page faults. It can decide what to do with not-present pages while the process that accessed the memory is paused. Possible choices include:



Swap: the page is swapped out. Allocate some real DRAM and read from disk into it, then return to the process.



Memory-mapped IO: similar, but reading from a specific file.



PCI/AGP space: the request goes over the bus to e.g. a GPU rather than main memory.



Zeros: either the operating system keeps some pre-zeroed DRAM ready, or it stops to write zeros to a page before giving it to you.



Invalid: finally, it's entirely possible for the operating system to not return at all and just kill the process that asked for that page. A common example is Linux memory "overcommit": processes can request and allocate more memory than available DRAM+swap space. This is fine as long as they don't use it. If they do all use it and the system runs out of real memory, it will start killing processes to recover the system. Other crisis situations might include memory mapped IO to a file over the network which has gone away, or swap on a drive which has failed.



You can deliberately allocate an unusable page (mmap option PROT_NONE on Linux). This is occasionally useful for finding certain kinds of bug.






share|improve this answer
























  • I'm not 100% sure, but if IIRC, Linux overcommit and OOM Killer are two different things: it may be that Process A requested the page that went over the limit of physical memory + swap; then the OOM killer kicks in, but it may decide to kill a different process, Process B, and in the end a valid page is served to A ("here's the page you requested; sorry that you had to wait, we were just busy killing other customers, so that we could serve you").

    – anrieff
    Dec 12 '18 at 15:54
















4














Virtual memory is a concept.



As anrieff says, systems which support virtual memory will have an MMU that actually handles the mapping. The processor will use virtual addresses, which may be any address in the 32 or 64 bit address space it supports. Virtual addresses aren't limited by the amount of physical memory.



As I mentioned in my comment, virtual memory does not have to map to anything. There are two sets of tables involved:




  • the MMU page tables, which may map to real physical memory or may not depending on the "present" bit. You can have pages which are not "present"; the MMU neither knows nor cares what they might contain, but they're not mapped to real physical DRAM. If you try to access one of these the system generates a page fault to the operating system.


  • the operating system keeps track of memory allocation to processes and itself, and takes responsibility for handling page faults. It can decide what to do with not-present pages while the process that accessed the memory is paused. Possible choices include:



Swap: the page is swapped out. Allocate some real DRAM and read from disk into it, then return to the process.



Memory-mapped IO: similar, but reading from a specific file.



PCI/AGP space: the request goes over the bus to e.g. a GPU rather than main memory.



Zeros: either the operating system keeps some pre-zeroed DRAM ready, or it stops to write zeros to a page before giving it to you.



Invalid: finally, it's entirely possible for the operating system to not return at all and just kill the process that asked for that page. A common example is Linux memory "overcommit": processes can request and allocate more memory than available DRAM+swap space. This is fine as long as they don't use it. If they do all use it and the system runs out of real memory, it will start killing processes to recover the system. Other crisis situations might include memory mapped IO to a file over the network which has gone away, or swap on a drive which has failed.



You can deliberately allocate an unusable page (mmap option PROT_NONE on Linux). This is occasionally useful for finding certain kinds of bug.






share|improve this answer
























  • I'm not 100% sure, but if IIRC, Linux overcommit and OOM Killer are two different things: it may be that Process A requested the page that went over the limit of physical memory + swap; then the OOM killer kicks in, but it may decide to kill a different process, Process B, and in the end a valid page is served to A ("here's the page you requested; sorry that you had to wait, we were just busy killing other customers, so that we could serve you").

    – anrieff
    Dec 12 '18 at 15:54














4












4








4







Virtual memory is a concept.



As anrieff says, systems which support virtual memory will have an MMU that actually handles the mapping. The processor will use virtual addresses, which may be any address in the 32 or 64 bit address space it supports. Virtual addresses aren't limited by the amount of physical memory.



As I mentioned in my comment, virtual memory does not have to map to anything. There are two sets of tables involved:




  • the MMU page tables, which may map to real physical memory or may not depending on the "present" bit. You can have pages which are not "present"; the MMU neither knows nor cares what they might contain, but they're not mapped to real physical DRAM. If you try to access one of these the system generates a page fault to the operating system.


  • the operating system keeps track of memory allocation to processes and itself, and takes responsibility for handling page faults. It can decide what to do with not-present pages while the process that accessed the memory is paused. Possible choices include:



Swap: the page is swapped out. Allocate some real DRAM and read from disk into it, then return to the process.



Memory-mapped IO: similar, but reading from a specific file.



PCI/AGP space: the request goes over the bus to e.g. a GPU rather than main memory.



Zeros: either the operating system keeps some pre-zeroed DRAM ready, or it stops to write zeros to a page before giving it to you.



Invalid: finally, it's entirely possible for the operating system to not return at all and just kill the process that asked for that page. A common example is Linux memory "overcommit": processes can request and allocate more memory than available DRAM+swap space. This is fine as long as they don't use it. If they do all use it and the system runs out of real memory, it will start killing processes to recover the system. Other crisis situations might include memory mapped IO to a file over the network which has gone away, or swap on a drive which has failed.



You can deliberately allocate an unusable page (mmap option PROT_NONE on Linux). This is occasionally useful for finding certain kinds of bug.






share|improve this answer













Virtual memory is a concept.



As anrieff says, systems which support virtual memory will have an MMU that actually handles the mapping. The processor will use virtual addresses, which may be any address in the 32 or 64 bit address space it supports. Virtual addresses aren't limited by the amount of physical memory.



As I mentioned in my comment, virtual memory does not have to map to anything. There are two sets of tables involved:




  • the MMU page tables, which may map to real physical memory or may not depending on the "present" bit. You can have pages which are not "present"; the MMU neither knows nor cares what they might contain, but they're not mapped to real physical DRAM. If you try to access one of these the system generates a page fault to the operating system.


  • the operating system keeps track of memory allocation to processes and itself, and takes responsibility for handling page faults. It can decide what to do with not-present pages while the process that accessed the memory is paused. Possible choices include:



Swap: the page is swapped out. Allocate some real DRAM and read from disk into it, then return to the process.



Memory-mapped IO: similar, but reading from a specific file.



PCI/AGP space: the request goes over the bus to e.g. a GPU rather than main memory.



Zeros: either the operating system keeps some pre-zeroed DRAM ready, or it stops to write zeros to a page before giving it to you.



Invalid: finally, it's entirely possible for the operating system to not return at all and just kill the process that asked for that page. A common example is Linux memory "overcommit": processes can request and allocate more memory than available DRAM+swap space. This is fine as long as they don't use it. If they do all use it and the system runs out of real memory, it will start killing processes to recover the system. Other crisis situations might include memory mapped IO to a file over the network which has gone away, or swap on a drive which has failed.



You can deliberately allocate an unusable page (mmap option PROT_NONE on Linux). This is occasionally useful for finding certain kinds of bug.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 12 '18 at 15:43









pjc50pjc50

5,6411826




5,6411826













  • I'm not 100% sure, but if IIRC, Linux overcommit and OOM Killer are two different things: it may be that Process A requested the page that went over the limit of physical memory + swap; then the OOM killer kicks in, but it may decide to kill a different process, Process B, and in the end a valid page is served to A ("here's the page you requested; sorry that you had to wait, we were just busy killing other customers, so that we could serve you").

    – anrieff
    Dec 12 '18 at 15:54



















  • I'm not 100% sure, but if IIRC, Linux overcommit and OOM Killer are two different things: it may be that Process A requested the page that went over the limit of physical memory + swap; then the OOM killer kicks in, but it may decide to kill a different process, Process B, and in the end a valid page is served to A ("here's the page you requested; sorry that you had to wait, we were just busy killing other customers, so that we could serve you").

    – anrieff
    Dec 12 '18 at 15:54

















I'm not 100% sure, but if IIRC, Linux overcommit and OOM Killer are two different things: it may be that Process A requested the page that went over the limit of physical memory + swap; then the OOM killer kicks in, but it may decide to kill a different process, Process B, and in the end a valid page is served to A ("here's the page you requested; sorry that you had to wait, we were just busy killing other customers, so that we could serve you").

– anrieff
Dec 12 '18 at 15:54





I'm not 100% sure, but if IIRC, Linux overcommit and OOM Killer are two different things: it may be that Process A requested the page that went over the limit of physical memory + swap; then the OOM killer kicks in, but it may decide to kill a different process, Process B, and in the end a valid page is served to A ("here's the page you requested; sorry that you had to wait, we were just busy killing other customers, so that we could serve you").

– anrieff
Dec 12 '18 at 15:54


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385536%2fis-virtual-memory-real-or-is-it-just-a-method-to-manage-the-memory%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]