**I want to move the resident/virtual data of a
SIGSTOP
ped process out of main memory and into any suitable swap. With the ability to revert the procedure before SIGCONT
inuing the process.**
The system does not have a dedicated swap space because normally I don't want things to be swapped. So a solution that writes to a dedicated file in a filesystem of my choice would be preferable. So, possibly "swap" is not entirely the correct word here, but if all else fails, a temporary swap space could be established.
Context: A program that takes *a long time* to start and wind down and is used intermittently uses not only a significant amount of cpu time while idle but also uses 60-80% of the system's memory. STOP/CONT works well to drop idle spinning, and even survives system suspends without problem, but while stopped, the system's memory effectively is reduced to 20-40%.
Using Linux' normal swapping behaviour a) makes it necessary to have a swap space that is normally not used outside of this particular scenario and more importantly b) is unreliable with regard to *when* it swaps out *what*. The wrong process might be swapped out or at a moment where it is inconvenient. Instead I have an SSD that can more than accommodate the resident set of the process, even the virtual set. And I want to control when or whether or not the swapping is to occur.
---
Possible approaches.
* [This serverfault answer](https://serverfault.com/questions/938431/is-there-a-way-to-force-a-single-process-to-swap-most-all-of-its-memory-to-disk/1152306#1152306) suggests madvise but there is no clear way to revert the procedure seeing as there is no counterpart to MADV_PAGEOUT
.
* Setting a specific file as swap for a process appears to be possible as per [Have a private swap file per process](https://unix.stackexchange.com/q/356202/9495) .
Asked by bitmask
(1246 rep)
Oct 21, 2024, 10:40 AM
Last activity: Apr 11, 2025, 11:18 AM
Last activity: Apr 11, 2025, 11:18 AM