How to re - load all running applications from swap room right into RAM?

If my desktop lacked memory and also swaps a whole lot after that I free or eliminate the application losing my RAM. Yet, afterwards, all my desktop/applications have been exchanged and also are badly slow-moving, do you recognize a means to "unswap" (reload from swap room right into RAM) my desktop/applications?

0
2019-05-18 22:37:13
Source Share
Answers: 3

If you actually have adequate RAM readily available once more you can utilize this series (as origin):

$ swapoff -a
$ swapon -a

(to compel the specific swap - in of all your applications)

(thinking that you are making use of linux)

0
2019-05-21 08:08:02
Source

swapon/swapoff will entirely clear your swap room, yet you can free several of it using the/ proc documents system also. You desire the first one:

# To free pagecache
echo 1 > /proc/sys/vm/drop_caches

# To free dentries and inodes
echo 2 > /proc/sys/vm/drop_caches

# To free pagecache, dentries and inodes
echo 3 > /proc/sys/vm/drop_caches

using http://linux-mm.org/Drop_Caches

0
2019-05-21 08:03:59
Source

The adhering to fast - and also - unclean python manuscript unloads the memory of a procedure to stdout. This has the negative effects of filling any kind of exchanged out web page or mapped documents. Call it as cat_proc_mem 123 456 789 where the debates are procedure IDs.

This manuscript is entirely details to Linux. It may be versatile to various other systems with a comparable /proc framework (Solaris?), yet forget running it on as an example *BSD. Also on Linux, you might require to transform the definition of c_pid_t and also the values of PTRACE_ATTACH and also PTRACE_DETACH. This is an evidence - of - concept manuscript, not suggested as an instance of excellent shows techniques. Usage at your very own threat.

Linux makes the memory of a procedure readily available as /proc/$pid/mem. Just particular address arrays are legible. These arrays can be located by reviewing the memory mapping details from the message documents /proc/$pid/maps. The pseudo - documents /proc/$pid/mem can not read by all procedures that have the approval to read it: the viewers procedure have to have called ptrace(PTRACE_ATTACH, $pid).

#!/usr/bin/env python
import ctypes, re, sys

## Partial interface to ptrace(2), only for PTRACE_ATTACH and PTRACE_DETACH.
c_ptrace = ctypes.CDLL("libc.so.6").ptrace
c_pid_t = ctypes.c_int32 # This assumes pid_t is int32_t
c_ptrace.argtypes = [ctypes.c_int, c_pid_t, ctypes.c_void_p, ctypes.c_void_p]
def ptrace(attach, pid):
    op = ctypes.c_int(16 if attach else 17) #PTRACE_ATTACH or PTRACE_DETACH
    c_pid = c_pid_t(pid)
    null = ctypes.c_void_p()
    err = c_ptrace(op, c_pid, null, null)
    if err != 0: raise SysError, 'ptrace', err

## Parse a line in /proc/$pid/maps. Return the boundaries of the chunk
## the read permission character.
def maps_line_range(line):
    m = re.match(r'([0-9A-Fa-f]+)-([0-9A-Fa-f]+) ([-r])', line)
    return [int(m.group(1), 16), int(m.group(2), 16), m.group(3)]

## Dump the readable chunks of memory mapped by a process
def cat_proc_mem(pid):
    ## Apparently we need to ptrace(PTRACE_ATTACH, $pid) to read /proc/$pid/mem
    ptrace(True, int(pid))
    ## Read the memory maps to see what address ranges are readable
    maps_file = open("/proc/" + pid + "/maps", 'r')
    ranges = map(maps_line_range, maps_file.readlines())
    maps_file.close()
    ## Read the readable mapped ranges
    mem_file = open("/proc/" + pid + "/mem", 'r', 0)
    for r in ranges:
        if r[2] == 'r':
            mem_file.seek(r[0])
            chunk = mem_file.read(r[1] - r[0])
            print chunk,
    mem_file.close()
    ## Cleanup
    ptrace(False, int(pid))

if __name__ == "__main__":
    for pid in sys.argv[1:]:
        cat_proc_mem(pid)

See additionally more information on .

unswap () {
  cat_proc_mem "[email protected]" >/dev/null
}
0
2019-05-21 06:25:37
Source