13
2
Is it possible to hint the Windows virtual-memory-manager to bring a particular process out of swap?
The situation I often find myself in is normally using about 50% of my RAM for all the normal programs, one in particular being an IDE for an embedded target, along with its associated debugger.
Then I leave a memory hungry process running - eg wireshark or something that's accumulating data over a weekend, everything gets swapped out - as they should. After the big process is finished, most processes are left in swap.
Then the sporadic pauses to swap the process back in cause problems with the debugger, presumably due to timing issues in the comms between IDE and the hardware-debugger. So control of the target device can be sporadic until enough attempts have brought the debug-data in the IDE back out of swap.
This is would be very useful! From the users' point of view, it is annoying to wait for the swapped off process after each click or user action. It would be much better to say: "unswap this process!", go for a coffee and return to a responsive system! – Tomas – 2013-12-11T11:28:49.940
I'm not familiar with the specifics of the swapping process of Windows but is this something you're looking for? There should be a working binary example in the comments.
– Rik – 2013-12-12T17:05:43.7101
I once had a similar question, and wrote a program based on the answers I got on Stack Overflow.
– Kerrek SB – 2013-12-16T23:37:16.733@Kerrek, I tried compiling your code under MinGW and got errors on each read "Failed to read one byte from 0x161000, error 299 (0 bytes read)." Since I only have Windows at work I wasn't brave enough to run the random binary you attached so the problem could be in my compilation. – Greg – 2013-12-17T05:44:16.937
But yes your approach sounds good, and exactly what I was looking for. – Greg – 2013-12-17T05:44:53.563
I told @KerrekSB to post his answer here. Greg, Kerrek, I also got lots of errors "Failed to read one byte from 0x....000, error 299 (0 bytes read)." But the tool works as a charm!!! So Greg I think it works, what do you think? – Tomas – 2013-12-18T11:00:15.657
@Greg: Yeah, I get those errors too and just ignore them. If you look at the code, you'll see that most pages are read fine, and there are only occasional errors. If anyone with Windows skills can tell me what the error means and how I should handle it, I'd welcome that, but note that it's totally benign. – Kerrek SB – 2013-12-18T11:04:18.663
1@KerrekSB, seems like minor problem. Maybe you are touching memory area which is not mapped? Anyway I think your answer deserves the bounty :) PS: the unswap seems much slower than it could be, compared to HDD speed. Seems that the bottleneck is somewhere else, but where? – Tomas – 2013-12-18T11:07:13.600
@Tomas I didn't get a chance to verify it - with the error happening and a very quick response I assumed nothing had happened, but then I wasn't massively overswapped at the time - I was just watching task-manager for signs of IO/unpaging. Its your rep to award and you've seen the proof. I'm convinced its the right solution assuming the app worked for you. – Greg – 2013-12-18T12:30:01.427
@KerrekSB it's your pity - you could have gained 50rep had you posted your answer; now the bounty will go waste. You have 10 minutes. – Tomas – 2013-12-19T10:58:59.937
@Tomas: That's perfectly fine. I got plenty of rep for the original question already :-) – Kerrek SB – 2013-12-19T11:15:24.440
@Tomas: The hint I got from Rik solved the problem: The erroneous pages are guard pages which aren't meant to be read. I added an explicit condition for that, so that the program should now run silently. – Kerrek SB – 2013-12-20T00:32:04.367
@KerrekSB great! I thought it will be something like this :) – Tomas – 2013-12-20T08:21:50.120