0

I'm reading about virtual memory swapping and it says that pages of memory can be swapped when an application becomes idle. I've tried to google what that means but haven't found much elaborate information except for this stackoverflow answer:

Your WinForms app is driven by a message loop that pulls messages out of a queue. When that queue is emptied, the message loop enters a quiet state, sleeping efficiently until the next message appears in the message queue. This helps conserve CPU processing resources (cycles wasted spinning in a loop takes CPU time away from other processes running on the machine, so everything feels slower) and also helps reduce power consumption / extend laptop battery life.

So does the application become idle when there's no messages in the message queue?

Community
  • 1
  • 1
Max Koretskyi
  • 101,079
  • 60
  • 333
  • 488
  • 1
    A process becomes "Idle" when there is no event to process. The CPU is then released for other processes that needs it. The OS being multitask, it gives back the control to the process when it needs the CPU to take into account new events. – Graffito Jul 17 '15 at 11:39
  • 1
    It sounds like what they are saying basically is that when an application is minimized in the GUI, loses focus, or otherwise is not actively being used, much of that application can be swapped out to disk to save room in memory – ControlAltDel Jul 17 '15 at 11:40
  • I think you have to read about computer architecture to understand in deep how the cpu and memory system works, what actually is a virtual memory etc. it is a bit advanced topic to explain just in a few lines. I recommend to take a look in "Computer organization and architecture" of William Stallings. What was your resources about VM swapping? – b10n1k Jul 18 '15 at 08:51
  • @b10n1k, thanks for the suggestion. I checked the book's reviews and is pretty contradictory, maybe you have another good suggestion for the read? And I don't remember where I read about swapping, it was some article – Max Koretskyi Jul 18 '15 at 12:45

1 Answers1

5

The operating system decides what idle means. In general, that means that the application doesn't actively utilize system resources (like processor cycles, IO operations, etc).

However, that doesn't mean that application's pages in memory will not be swapped if the application isn't 'idle'. There may be many 'active' applications which contend for the same limited physical memory and the OS may be forced to swap some pages belonging to an active application to make room for another active application.

Dragan Bozanovic
  • 23,102
  • 5
  • 43
  • 110
  • so does it have nothing to do with message queue? – Max Koretskyi Jul 17 '15 at 13:55
  • 2
    It has absolutely nothing to do with any message queues. The question you linked to talks about some completely different concept (GUI event fired when all other pending GUI events have been processed). – Dragan Bozanovic Jul 17 '15 at 14:07