Swap Memory (Virtual Ram) Problem!

I Have 4 Gb Actual ram And 6 GB swap

whenever I open high memory usage software like visual studio (code editor ) then actual ram goes 90-95% and swap just use 200MB

how to solve that?
it can be possible to do that whenever selected software opens it should use swap instead of actual ram

The question is why would you do that? What would you achieve with that? The RAM is there for to be used, swap is slooooow compared to RAM.

cuz I am using JB's rider and its use RAM 90 to 95 % so no other software can work nicely

@Storm What Should I Do Now??

Read this: How can I limit the CPU and RAM usage for a process? - Ask Ubuntu

if I set a limit on ram and CPU it will use swap or not

No, but it will keep you computers RAM free for other tasks. JB's rider needs to swap because of limit of RAM if it doesn't you probably loose your work while working on it.

is there any safer solution

Hold on... I'll check the web if there's a safer solution.

1 Like

This might something you that looks promising: Limit memory usage for a single Linux process - Unix & Linux Stack Exchange

is this Good to try ?

Another way to limit this is to use Linux's control groups. This is especially useful if you want to limit a process's (or group of processes') allocation of physical memory distinctly from virtual memory. For example:

cgcreate -g memory:myGroup
echo 500M > /sys/fs/cgroup/memory/myGroup/memory.limit_in_bytes
echo 5G > /sys/fs/cgroup/memory/myGroup/memory.memsw.limit_in_bytes

will create a control group named myGroup, cap the set of processes run under myGroup up to 500 MB of physical memory with memory.limit_in_bytes and up to 5000 MB of physical and swap memory together with memory.memsw.limit_in_bytes. More info about these options can be found here: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/sec-memory

To run a process under the control group:

cgexec -g memory:myGroup pdftoppm

Note that on a modern Ubuntu distribution this example requires installing the cgroup-bin package and editing /etc/default/grub to change GRUB_CMDLINE_LINUX_DEFAULT to:

GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory swapaccount=1"

and then running sudo update-grub and rebooting to boot with the new kernel boot parameters.

Looks good in my eye, but you might wait for a second opinion for safty, as I have no intention to test on my machine. I still think it's a bad idea to mess the OS memory allocations system, but that's just my opinion. :slight_smile:

1 Like

thank You very much, @Storm

Btw I found this on the web

swap - How do I configure swappiness? - Ask Ubuntu
A swappiness setting of zero means that the disk will be avoided unless absolutely necessary (you run out of memory), while a swappiness setting of 100 means that programs will be swapped to disk almost instantly. -In topic

That's good found. I suggest you try that first, as it's easier to reverse if it goes wrong.

1 Like

So my current swappiness is 60 and it's using 500Mb while rider is active,
I should make to 100 directly or something else

100 is to extreme try 80 first.

1 Like

in terminal it shows 80
when i open it in text it shows 15
:thinking: :thinking: :thinking:

sudo nano /proc/sys/vm/swappiness

remember to reboot.

Does it work as expected?

No now using 77%Ram and 268mb swap
Also software runs with too much lag