My app has several JVMs running in Linux and swap usage is mostly zero. However, sometimes by high traffic or slowness of database, JVMs consume swap memory, which is not recommended. If it happens, my plan is to recycle swap by 'swap off/swap on' without app shutdown at night window.
When I swap off on OS, what happens to processes that consume swap memory? Are they losing allocated memory blocks? Or does the OS move swap memory blocks back to physical memory? I'm asking under the assumption that physical memory has enough free space to take all swap usage.
The reason that I'm searching for recycling swap is because of swap usage behavior; processes are not consuming swap when swap usage is zero, but they start consuming it more and more when swap usage is non-zero even when there are plenty of physical memory available.
My question is dealing with actual practice when a server hits heavy demand and uses swap memory, and never goes back after heavy demand is gone.