Do I need to clear out swap to make my computer fast again?
I ran a process which used up mostly all my RAM and Swap... I was forced to kill the process, but now I see something strange, my Swap usage has decreased a little bit, but it is still half used while my RAM is barely being used at all... In fact quite a lot more Swap is being used than RAM, and even though the RAM usage level is low, my computer is being really slow and I am assuming that this is linked to the Swap levels still being high? If so, how do I clear my Swap if it doesn't automatically? Or what do I do? I have already looked at this question, it does not appear to only be talking about Swap and I don't want to affect the RAM, so a solution would be clearing Swap, but only Swap...
Last time this happened I was forced to just restart my machine, but I should have to. I am running Ubuntu GNOME 15.10 with GNOME 3.18.
performance swap
add a comment |
I ran a process which used up mostly all my RAM and Swap... I was forced to kill the process, but now I see something strange, my Swap usage has decreased a little bit, but it is still half used while my RAM is barely being used at all... In fact quite a lot more Swap is being used than RAM, and even though the RAM usage level is low, my computer is being really slow and I am assuming that this is linked to the Swap levels still being high? If so, how do I clear my Swap if it doesn't automatically? Or what do I do? I have already looked at this question, it does not appear to only be talking about Swap and I don't want to affect the RAM, so a solution would be clearing Swap, but only Swap...
Last time this happened I was forced to just restart my machine, but I should have to. I am running Ubuntu GNOME 15.10 with GNOME 3.18.
performance swap
Possible duplicate of How do I clean or disable the memory cache?
– Sergiy Kolodyazhnyy
Apr 11 '16 at 22:51
@Serg, not a duplicate.. at least of that question.
– psusi
Apr 11 '16 at 23:28
add a comment |
I ran a process which used up mostly all my RAM and Swap... I was forced to kill the process, but now I see something strange, my Swap usage has decreased a little bit, but it is still half used while my RAM is barely being used at all... In fact quite a lot more Swap is being used than RAM, and even though the RAM usage level is low, my computer is being really slow and I am assuming that this is linked to the Swap levels still being high? If so, how do I clear my Swap if it doesn't automatically? Or what do I do? I have already looked at this question, it does not appear to only be talking about Swap and I don't want to affect the RAM, so a solution would be clearing Swap, but only Swap...
Last time this happened I was forced to just restart my machine, but I should have to. I am running Ubuntu GNOME 15.10 with GNOME 3.18.
performance swap
I ran a process which used up mostly all my RAM and Swap... I was forced to kill the process, but now I see something strange, my Swap usage has decreased a little bit, but it is still half used while my RAM is barely being used at all... In fact quite a lot more Swap is being used than RAM, and even though the RAM usage level is low, my computer is being really slow and I am assuming that this is linked to the Swap levels still being high? If so, how do I clear my Swap if it doesn't automatically? Or what do I do? I have already looked at this question, it does not appear to only be talking about Swap and I don't want to affect the RAM, so a solution would be clearing Swap, but only Swap...
Last time this happened I was forced to just restart my machine, but I should have to. I am running Ubuntu GNOME 15.10 with GNOME 3.18.
performance swap
performance swap
edited Apr 11 '16 at 23:02
asked Apr 11 '16 at 22:48
user364819
Possible duplicate of How do I clean or disable the memory cache?
– Sergiy Kolodyazhnyy
Apr 11 '16 at 22:51
@Serg, not a duplicate.. at least of that question.
– psusi
Apr 11 '16 at 23:28
add a comment |
Possible duplicate of How do I clean or disable the memory cache?
– Sergiy Kolodyazhnyy
Apr 11 '16 at 22:51
@Serg, not a duplicate.. at least of that question.
– psusi
Apr 11 '16 at 23:28
Possible duplicate of How do I clean or disable the memory cache?
– Sergiy Kolodyazhnyy
Apr 11 '16 at 22:51
Possible duplicate of How do I clean or disable the memory cache?
– Sergiy Kolodyazhnyy
Apr 11 '16 at 22:51
@Serg, not a duplicate.. at least of that question.
– psusi
Apr 11 '16 at 23:28
@Serg, not a duplicate.. at least of that question.
– psusi
Apr 11 '16 at 23:28
add a comment |
4 Answers
4
active
oldest
votes
Once data goes into swap, it is normal for it to stay there even once your memory starts to free up again. It is a good thing and there is no need for concern.
Due to hard disk access being significantly slower than memory, your system will avoid swapping data in or out of swap when it doesn't think it is necessary for system performance or stability. So, data will only go into swap when the system is running out of free memory or there is a lot of pressure on the disk cache, and your system decides the time-consuming process of placing data into swap will pay off with better or more reliable system performance afterwards.
Transferring data out of swap is (for traditional hard disks, at least) just as time-consuming as putting it in there. So your system will be reluctant to remove data from swap if it's not actually being used. If you have data in swap and it's not being used, then it's actually a good thing that it remains in swap, since it leaves more free memory for other things that are being used, potentially speeding up your system.
The best way to completely avoid swapping is to buy more physical RAM if that's possible. When it swaps, your system is giving you the best performance it can with the amount of physical memory it has.
All that said, if you are sure that the low-memory/high cache event that caused the swap in the first place won't happen again and you don't mind waiting, you can force the system to release all of its swap data with the following commands.
sudo swapoff -a
sudo swapon -a
This will disable then re-enable swap, forcing data out of it in the process. As explained, there is probably no real reason to do this - beyond curiosity or seeing how your swap is working.
So when my Swap stays at like 90% used, and my RAM is at 10%... Why does my computer become incredibly slow?
– user364819
Apr 12 '16 at 10:55
Two possibilities. One is that the slowness is unrelated, which I suspect to be the case. Another is that whatever event that caused all that data to be pushed to swap put so much pressure on available memory that your system was forced to push some more active data to swap just to avoid killing processes, and that is now being swapped back because it's needed. That slowness would only last a short time though if that's the case, and it can still be attributed to whatever event used up all your RAM in the first place.
– thomasrutter
Apr 13 '16 at 0:44
I am sure that it is related because I have been running some tests and my computer is always fine and fast except when I have Swap usage, and more Swap is used, the slower it gets... And it lasts seemingly until I restart my machine and Swap is cleared, so it is rather strange, is there no way of further analysing this or seeing what is actually going on?
– user364819
Apr 13 '16 at 9:35
Try to think of the swap usage as your system's way of responding to the problem rather than the cause of it. The root cause will be whatever memory or cache-intensive event caused the swapping to occur (you haven't given much info about this) - fix that or get more physical RAM. To see how your system would perform were it not for swap, try disabling swap and running that problem process again. Assuming it does the same thing, it may crash sooner, and if it doesn't you'll possibly get the same or more slowness.
– thomasrutter
Apr 14 '16 at 1:51
I ran a command giving a huge number tobc
, then when it became unresponsive and used up all my RAM and a lot of my Swap, I killed it, the RAM went down to normal levels, but the slowness stayed and so did the levels of Swap usage.
– user364819
Apr 14 '16 at 9:58
|
show 3 more comments
The slowness will quickly clear up on its own as the swapped out data is brought back in when it is needed. It won't be swapped out again as long as you have plenty of free ram, but plenty of other data that you have not accessed might still remain in swap, waiting for you to actually need it again.
add a comment |
If you have a fast cpu, try Zram.
You can read about it in detail here.
add a comment |
Clearing swap would do nothing for the slowness of your computer and does not need to be done except if you believe that some incorrectly behaving program has kept some sensitive data (e.g. passwords) in swappable memory that may have ended on the swap partition. If you don't need to wipe potentially sensitive data out of swap, you never need to manually clean or format the swap once it's working.
The most probable reason your system feels slow is that the system is in fact going nearly out of RAM. This may happen even if the system monitor shows that the system still has available memory because memory need is often sporadic and the memory may be needed only for a less than a second and will not show up in any slow refreshing system monitor.
The most simple way is to open a terminal and run command sudo vmstat -SM 10
(you may need to install vmstat
first by running sudo apt install vmstat
):
Output will look something like this (new line appears every 10 seconds):
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 1609 6565 13230 0 0 88 195 17 178 44 10 45 1 0
1 0 0 1599 6565 13232 0 0 0 226 4621 18688 22 6 72 0 0
4 0 0 1566 6565 13234 0 0 0 67 5217 20819 27 7 65 1 0
2 0 0 1533 6566 13241 0 0 0 847 6021 23359 35 6 58 0 0
The fields you want to watch are swap
si
and so
which means number of megabytes in 10 second period that are swapped in (from swap device to RAM) or swapped out. Usually the so
does not matter for system speed but si
will cause slowness and is caused by system having too small RAM for the processes that you're trying to run in paraller. The possible solutions are (1) close one or more applications that you're using, or (2) get more physical RAM.
Press Ctrl+C to exit vmstat
.
Note that vmstat
is not able to tell if system goes near zero free memory for short moments so free
, buff
and cache
may have big numbers even if memory is slow. sar
is probably the only program that can tell for sure if your memory is running out but that program is pretty hard to configure (not impossible, though - just install it and start with man sar
).
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f756391%2fdo-i-need-to-clear-out-swap-to-make-my-computer-fast-again%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Once data goes into swap, it is normal for it to stay there even once your memory starts to free up again. It is a good thing and there is no need for concern.
Due to hard disk access being significantly slower than memory, your system will avoid swapping data in or out of swap when it doesn't think it is necessary for system performance or stability. So, data will only go into swap when the system is running out of free memory or there is a lot of pressure on the disk cache, and your system decides the time-consuming process of placing data into swap will pay off with better or more reliable system performance afterwards.
Transferring data out of swap is (for traditional hard disks, at least) just as time-consuming as putting it in there. So your system will be reluctant to remove data from swap if it's not actually being used. If you have data in swap and it's not being used, then it's actually a good thing that it remains in swap, since it leaves more free memory for other things that are being used, potentially speeding up your system.
The best way to completely avoid swapping is to buy more physical RAM if that's possible. When it swaps, your system is giving you the best performance it can with the amount of physical memory it has.
All that said, if you are sure that the low-memory/high cache event that caused the swap in the first place won't happen again and you don't mind waiting, you can force the system to release all of its swap data with the following commands.
sudo swapoff -a
sudo swapon -a
This will disable then re-enable swap, forcing data out of it in the process. As explained, there is probably no real reason to do this - beyond curiosity or seeing how your swap is working.
So when my Swap stays at like 90% used, and my RAM is at 10%... Why does my computer become incredibly slow?
– user364819
Apr 12 '16 at 10:55
Two possibilities. One is that the slowness is unrelated, which I suspect to be the case. Another is that whatever event that caused all that data to be pushed to swap put so much pressure on available memory that your system was forced to push some more active data to swap just to avoid killing processes, and that is now being swapped back because it's needed. That slowness would only last a short time though if that's the case, and it can still be attributed to whatever event used up all your RAM in the first place.
– thomasrutter
Apr 13 '16 at 0:44
I am sure that it is related because I have been running some tests and my computer is always fine and fast except when I have Swap usage, and more Swap is used, the slower it gets... And it lasts seemingly until I restart my machine and Swap is cleared, so it is rather strange, is there no way of further analysing this or seeing what is actually going on?
– user364819
Apr 13 '16 at 9:35
Try to think of the swap usage as your system's way of responding to the problem rather than the cause of it. The root cause will be whatever memory or cache-intensive event caused the swapping to occur (you haven't given much info about this) - fix that or get more physical RAM. To see how your system would perform were it not for swap, try disabling swap and running that problem process again. Assuming it does the same thing, it may crash sooner, and if it doesn't you'll possibly get the same or more slowness.
– thomasrutter
Apr 14 '16 at 1:51
I ran a command giving a huge number tobc
, then when it became unresponsive and used up all my RAM and a lot of my Swap, I killed it, the RAM went down to normal levels, but the slowness stayed and so did the levels of Swap usage.
– user364819
Apr 14 '16 at 9:58
|
show 3 more comments
Once data goes into swap, it is normal for it to stay there even once your memory starts to free up again. It is a good thing and there is no need for concern.
Due to hard disk access being significantly slower than memory, your system will avoid swapping data in or out of swap when it doesn't think it is necessary for system performance or stability. So, data will only go into swap when the system is running out of free memory or there is a lot of pressure on the disk cache, and your system decides the time-consuming process of placing data into swap will pay off with better or more reliable system performance afterwards.
Transferring data out of swap is (for traditional hard disks, at least) just as time-consuming as putting it in there. So your system will be reluctant to remove data from swap if it's not actually being used. If you have data in swap and it's not being used, then it's actually a good thing that it remains in swap, since it leaves more free memory for other things that are being used, potentially speeding up your system.
The best way to completely avoid swapping is to buy more physical RAM if that's possible. When it swaps, your system is giving you the best performance it can with the amount of physical memory it has.
All that said, if you are sure that the low-memory/high cache event that caused the swap in the first place won't happen again and you don't mind waiting, you can force the system to release all of its swap data with the following commands.
sudo swapoff -a
sudo swapon -a
This will disable then re-enable swap, forcing data out of it in the process. As explained, there is probably no real reason to do this - beyond curiosity or seeing how your swap is working.
So when my Swap stays at like 90% used, and my RAM is at 10%... Why does my computer become incredibly slow?
– user364819
Apr 12 '16 at 10:55
Two possibilities. One is that the slowness is unrelated, which I suspect to be the case. Another is that whatever event that caused all that data to be pushed to swap put so much pressure on available memory that your system was forced to push some more active data to swap just to avoid killing processes, and that is now being swapped back because it's needed. That slowness would only last a short time though if that's the case, and it can still be attributed to whatever event used up all your RAM in the first place.
– thomasrutter
Apr 13 '16 at 0:44
I am sure that it is related because I have been running some tests and my computer is always fine and fast except when I have Swap usage, and more Swap is used, the slower it gets... And it lasts seemingly until I restart my machine and Swap is cleared, so it is rather strange, is there no way of further analysing this or seeing what is actually going on?
– user364819
Apr 13 '16 at 9:35
Try to think of the swap usage as your system's way of responding to the problem rather than the cause of it. The root cause will be whatever memory or cache-intensive event caused the swapping to occur (you haven't given much info about this) - fix that or get more physical RAM. To see how your system would perform were it not for swap, try disabling swap and running that problem process again. Assuming it does the same thing, it may crash sooner, and if it doesn't you'll possibly get the same or more slowness.
– thomasrutter
Apr 14 '16 at 1:51
I ran a command giving a huge number tobc
, then when it became unresponsive and used up all my RAM and a lot of my Swap, I killed it, the RAM went down to normal levels, but the slowness stayed and so did the levels of Swap usage.
– user364819
Apr 14 '16 at 9:58
|
show 3 more comments
Once data goes into swap, it is normal for it to stay there even once your memory starts to free up again. It is a good thing and there is no need for concern.
Due to hard disk access being significantly slower than memory, your system will avoid swapping data in or out of swap when it doesn't think it is necessary for system performance or stability. So, data will only go into swap when the system is running out of free memory or there is a lot of pressure on the disk cache, and your system decides the time-consuming process of placing data into swap will pay off with better or more reliable system performance afterwards.
Transferring data out of swap is (for traditional hard disks, at least) just as time-consuming as putting it in there. So your system will be reluctant to remove data from swap if it's not actually being used. If you have data in swap and it's not being used, then it's actually a good thing that it remains in swap, since it leaves more free memory for other things that are being used, potentially speeding up your system.
The best way to completely avoid swapping is to buy more physical RAM if that's possible. When it swaps, your system is giving you the best performance it can with the amount of physical memory it has.
All that said, if you are sure that the low-memory/high cache event that caused the swap in the first place won't happen again and you don't mind waiting, you can force the system to release all of its swap data with the following commands.
sudo swapoff -a
sudo swapon -a
This will disable then re-enable swap, forcing data out of it in the process. As explained, there is probably no real reason to do this - beyond curiosity or seeing how your swap is working.
Once data goes into swap, it is normal for it to stay there even once your memory starts to free up again. It is a good thing and there is no need for concern.
Due to hard disk access being significantly slower than memory, your system will avoid swapping data in or out of swap when it doesn't think it is necessary for system performance or stability. So, data will only go into swap when the system is running out of free memory or there is a lot of pressure on the disk cache, and your system decides the time-consuming process of placing data into swap will pay off with better or more reliable system performance afterwards.
Transferring data out of swap is (for traditional hard disks, at least) just as time-consuming as putting it in there. So your system will be reluctant to remove data from swap if it's not actually being used. If you have data in swap and it's not being used, then it's actually a good thing that it remains in swap, since it leaves more free memory for other things that are being used, potentially speeding up your system.
The best way to completely avoid swapping is to buy more physical RAM if that's possible. When it swaps, your system is giving you the best performance it can with the amount of physical memory it has.
All that said, if you are sure that the low-memory/high cache event that caused the swap in the first place won't happen again and you don't mind waiting, you can force the system to release all of its swap data with the following commands.
sudo swapoff -a
sudo swapon -a
This will disable then re-enable swap, forcing data out of it in the process. As explained, there is probably no real reason to do this - beyond curiosity or seeing how your swap is working.
edited Apr 12 '16 at 0:56
answered Apr 12 '16 at 0:50
thomasrutterthomasrutter
26.5k46389
26.5k46389
So when my Swap stays at like 90% used, and my RAM is at 10%... Why does my computer become incredibly slow?
– user364819
Apr 12 '16 at 10:55
Two possibilities. One is that the slowness is unrelated, which I suspect to be the case. Another is that whatever event that caused all that data to be pushed to swap put so much pressure on available memory that your system was forced to push some more active data to swap just to avoid killing processes, and that is now being swapped back because it's needed. That slowness would only last a short time though if that's the case, and it can still be attributed to whatever event used up all your RAM in the first place.
– thomasrutter
Apr 13 '16 at 0:44
I am sure that it is related because I have been running some tests and my computer is always fine and fast except when I have Swap usage, and more Swap is used, the slower it gets... And it lasts seemingly until I restart my machine and Swap is cleared, so it is rather strange, is there no way of further analysing this or seeing what is actually going on?
– user364819
Apr 13 '16 at 9:35
Try to think of the swap usage as your system's way of responding to the problem rather than the cause of it. The root cause will be whatever memory or cache-intensive event caused the swapping to occur (you haven't given much info about this) - fix that or get more physical RAM. To see how your system would perform were it not for swap, try disabling swap and running that problem process again. Assuming it does the same thing, it may crash sooner, and if it doesn't you'll possibly get the same or more slowness.
– thomasrutter
Apr 14 '16 at 1:51
I ran a command giving a huge number tobc
, then when it became unresponsive and used up all my RAM and a lot of my Swap, I killed it, the RAM went down to normal levels, but the slowness stayed and so did the levels of Swap usage.
– user364819
Apr 14 '16 at 9:58
|
show 3 more comments
So when my Swap stays at like 90% used, and my RAM is at 10%... Why does my computer become incredibly slow?
– user364819
Apr 12 '16 at 10:55
Two possibilities. One is that the slowness is unrelated, which I suspect to be the case. Another is that whatever event that caused all that data to be pushed to swap put so much pressure on available memory that your system was forced to push some more active data to swap just to avoid killing processes, and that is now being swapped back because it's needed. That slowness would only last a short time though if that's the case, and it can still be attributed to whatever event used up all your RAM in the first place.
– thomasrutter
Apr 13 '16 at 0:44
I am sure that it is related because I have been running some tests and my computer is always fine and fast except when I have Swap usage, and more Swap is used, the slower it gets... And it lasts seemingly until I restart my machine and Swap is cleared, so it is rather strange, is there no way of further analysing this or seeing what is actually going on?
– user364819
Apr 13 '16 at 9:35
Try to think of the swap usage as your system's way of responding to the problem rather than the cause of it. The root cause will be whatever memory or cache-intensive event caused the swapping to occur (you haven't given much info about this) - fix that or get more physical RAM. To see how your system would perform were it not for swap, try disabling swap and running that problem process again. Assuming it does the same thing, it may crash sooner, and if it doesn't you'll possibly get the same or more slowness.
– thomasrutter
Apr 14 '16 at 1:51
I ran a command giving a huge number tobc
, then when it became unresponsive and used up all my RAM and a lot of my Swap, I killed it, the RAM went down to normal levels, but the slowness stayed and so did the levels of Swap usage.
– user364819
Apr 14 '16 at 9:58
So when my Swap stays at like 90% used, and my RAM is at 10%... Why does my computer become incredibly slow?
– user364819
Apr 12 '16 at 10:55
So when my Swap stays at like 90% used, and my RAM is at 10%... Why does my computer become incredibly slow?
– user364819
Apr 12 '16 at 10:55
Two possibilities. One is that the slowness is unrelated, which I suspect to be the case. Another is that whatever event that caused all that data to be pushed to swap put so much pressure on available memory that your system was forced to push some more active data to swap just to avoid killing processes, and that is now being swapped back because it's needed. That slowness would only last a short time though if that's the case, and it can still be attributed to whatever event used up all your RAM in the first place.
– thomasrutter
Apr 13 '16 at 0:44
Two possibilities. One is that the slowness is unrelated, which I suspect to be the case. Another is that whatever event that caused all that data to be pushed to swap put so much pressure on available memory that your system was forced to push some more active data to swap just to avoid killing processes, and that is now being swapped back because it's needed. That slowness would only last a short time though if that's the case, and it can still be attributed to whatever event used up all your RAM in the first place.
– thomasrutter
Apr 13 '16 at 0:44
I am sure that it is related because I have been running some tests and my computer is always fine and fast except when I have Swap usage, and more Swap is used, the slower it gets... And it lasts seemingly until I restart my machine and Swap is cleared, so it is rather strange, is there no way of further analysing this or seeing what is actually going on?
– user364819
Apr 13 '16 at 9:35
I am sure that it is related because I have been running some tests and my computer is always fine and fast except when I have Swap usage, and more Swap is used, the slower it gets... And it lasts seemingly until I restart my machine and Swap is cleared, so it is rather strange, is there no way of further analysing this or seeing what is actually going on?
– user364819
Apr 13 '16 at 9:35
Try to think of the swap usage as your system's way of responding to the problem rather than the cause of it. The root cause will be whatever memory or cache-intensive event caused the swapping to occur (you haven't given much info about this) - fix that or get more physical RAM. To see how your system would perform were it not for swap, try disabling swap and running that problem process again. Assuming it does the same thing, it may crash sooner, and if it doesn't you'll possibly get the same or more slowness.
– thomasrutter
Apr 14 '16 at 1:51
Try to think of the swap usage as your system's way of responding to the problem rather than the cause of it. The root cause will be whatever memory or cache-intensive event caused the swapping to occur (you haven't given much info about this) - fix that or get more physical RAM. To see how your system would perform were it not for swap, try disabling swap and running that problem process again. Assuming it does the same thing, it may crash sooner, and if it doesn't you'll possibly get the same or more slowness.
– thomasrutter
Apr 14 '16 at 1:51
I ran a command giving a huge number to
bc
, then when it became unresponsive and used up all my RAM and a lot of my Swap, I killed it, the RAM went down to normal levels, but the slowness stayed and so did the levels of Swap usage.– user364819
Apr 14 '16 at 9:58
I ran a command giving a huge number to
bc
, then when it became unresponsive and used up all my RAM and a lot of my Swap, I killed it, the RAM went down to normal levels, but the slowness stayed and so did the levels of Swap usage.– user364819
Apr 14 '16 at 9:58
|
show 3 more comments
The slowness will quickly clear up on its own as the swapped out data is brought back in when it is needed. It won't be swapped out again as long as you have plenty of free ram, but plenty of other data that you have not accessed might still remain in swap, waiting for you to actually need it again.
add a comment |
The slowness will quickly clear up on its own as the swapped out data is brought back in when it is needed. It won't be swapped out again as long as you have plenty of free ram, but plenty of other data that you have not accessed might still remain in swap, waiting for you to actually need it again.
add a comment |
The slowness will quickly clear up on its own as the swapped out data is brought back in when it is needed. It won't be swapped out again as long as you have plenty of free ram, but plenty of other data that you have not accessed might still remain in swap, waiting for you to actually need it again.
The slowness will quickly clear up on its own as the swapped out data is brought back in when it is needed. It won't be swapped out again as long as you have plenty of free ram, but plenty of other data that you have not accessed might still remain in swap, waiting for you to actually need it again.
answered Apr 11 '16 at 23:30
psusipsusi
31k15088
31k15088
add a comment |
add a comment |
If you have a fast cpu, try Zram.
You can read about it in detail here.
add a comment |
If you have a fast cpu, try Zram.
You can read about it in detail here.
add a comment |
If you have a fast cpu, try Zram.
You can read about it in detail here.
If you have a fast cpu, try Zram.
You can read about it in detail here.
edited Apr 13 '17 at 12:24
Community♦
1
1
answered Apr 12 '16 at 14:47
Sirajus SalekinSirajus Salekin
1,050620
1,050620
add a comment |
add a comment |
Clearing swap would do nothing for the slowness of your computer and does not need to be done except if you believe that some incorrectly behaving program has kept some sensitive data (e.g. passwords) in swappable memory that may have ended on the swap partition. If you don't need to wipe potentially sensitive data out of swap, you never need to manually clean or format the swap once it's working.
The most probable reason your system feels slow is that the system is in fact going nearly out of RAM. This may happen even if the system monitor shows that the system still has available memory because memory need is often sporadic and the memory may be needed only for a less than a second and will not show up in any slow refreshing system monitor.
The most simple way is to open a terminal and run command sudo vmstat -SM 10
(you may need to install vmstat
first by running sudo apt install vmstat
):
Output will look something like this (new line appears every 10 seconds):
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 1609 6565 13230 0 0 88 195 17 178 44 10 45 1 0
1 0 0 1599 6565 13232 0 0 0 226 4621 18688 22 6 72 0 0
4 0 0 1566 6565 13234 0 0 0 67 5217 20819 27 7 65 1 0
2 0 0 1533 6566 13241 0 0 0 847 6021 23359 35 6 58 0 0
The fields you want to watch are swap
si
and so
which means number of megabytes in 10 second period that are swapped in (from swap device to RAM) or swapped out. Usually the so
does not matter for system speed but si
will cause slowness and is caused by system having too small RAM for the processes that you're trying to run in paraller. The possible solutions are (1) close one or more applications that you're using, or (2) get more physical RAM.
Press Ctrl+C to exit vmstat
.
Note that vmstat
is not able to tell if system goes near zero free memory for short moments so free
, buff
and cache
may have big numbers even if memory is slow. sar
is probably the only program that can tell for sure if your memory is running out but that program is pretty hard to configure (not impossible, though - just install it and start with man sar
).
add a comment |
Clearing swap would do nothing for the slowness of your computer and does not need to be done except if you believe that some incorrectly behaving program has kept some sensitive data (e.g. passwords) in swappable memory that may have ended on the swap partition. If you don't need to wipe potentially sensitive data out of swap, you never need to manually clean or format the swap once it's working.
The most probable reason your system feels slow is that the system is in fact going nearly out of RAM. This may happen even if the system monitor shows that the system still has available memory because memory need is often sporadic and the memory may be needed only for a less than a second and will not show up in any slow refreshing system monitor.
The most simple way is to open a terminal and run command sudo vmstat -SM 10
(you may need to install vmstat
first by running sudo apt install vmstat
):
Output will look something like this (new line appears every 10 seconds):
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 1609 6565 13230 0 0 88 195 17 178 44 10 45 1 0
1 0 0 1599 6565 13232 0 0 0 226 4621 18688 22 6 72 0 0
4 0 0 1566 6565 13234 0 0 0 67 5217 20819 27 7 65 1 0
2 0 0 1533 6566 13241 0 0 0 847 6021 23359 35 6 58 0 0
The fields you want to watch are swap
si
and so
which means number of megabytes in 10 second period that are swapped in (from swap device to RAM) or swapped out. Usually the so
does not matter for system speed but si
will cause slowness and is caused by system having too small RAM for the processes that you're trying to run in paraller. The possible solutions are (1) close one or more applications that you're using, or (2) get more physical RAM.
Press Ctrl+C to exit vmstat
.
Note that vmstat
is not able to tell if system goes near zero free memory for short moments so free
, buff
and cache
may have big numbers even if memory is slow. sar
is probably the only program that can tell for sure if your memory is running out but that program is pretty hard to configure (not impossible, though - just install it and start with man sar
).
add a comment |
Clearing swap would do nothing for the slowness of your computer and does not need to be done except if you believe that some incorrectly behaving program has kept some sensitive data (e.g. passwords) in swappable memory that may have ended on the swap partition. If you don't need to wipe potentially sensitive data out of swap, you never need to manually clean or format the swap once it's working.
The most probable reason your system feels slow is that the system is in fact going nearly out of RAM. This may happen even if the system monitor shows that the system still has available memory because memory need is often sporadic and the memory may be needed only for a less than a second and will not show up in any slow refreshing system monitor.
The most simple way is to open a terminal and run command sudo vmstat -SM 10
(you may need to install vmstat
first by running sudo apt install vmstat
):
Output will look something like this (new line appears every 10 seconds):
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 1609 6565 13230 0 0 88 195 17 178 44 10 45 1 0
1 0 0 1599 6565 13232 0 0 0 226 4621 18688 22 6 72 0 0
4 0 0 1566 6565 13234 0 0 0 67 5217 20819 27 7 65 1 0
2 0 0 1533 6566 13241 0 0 0 847 6021 23359 35 6 58 0 0
The fields you want to watch are swap
si
and so
which means number of megabytes in 10 second period that are swapped in (from swap device to RAM) or swapped out. Usually the so
does not matter for system speed but si
will cause slowness and is caused by system having too small RAM for the processes that you're trying to run in paraller. The possible solutions are (1) close one or more applications that you're using, or (2) get more physical RAM.
Press Ctrl+C to exit vmstat
.
Note that vmstat
is not able to tell if system goes near zero free memory for short moments so free
, buff
and cache
may have big numbers even if memory is slow. sar
is probably the only program that can tell for sure if your memory is running out but that program is pretty hard to configure (not impossible, though - just install it and start with man sar
).
Clearing swap would do nothing for the slowness of your computer and does not need to be done except if you believe that some incorrectly behaving program has kept some sensitive data (e.g. passwords) in swappable memory that may have ended on the swap partition. If you don't need to wipe potentially sensitive data out of swap, you never need to manually clean or format the swap once it's working.
The most probable reason your system feels slow is that the system is in fact going nearly out of RAM. This may happen even if the system monitor shows that the system still has available memory because memory need is often sporadic and the memory may be needed only for a less than a second and will not show up in any slow refreshing system monitor.
The most simple way is to open a terminal and run command sudo vmstat -SM 10
(you may need to install vmstat
first by running sudo apt install vmstat
):
Output will look something like this (new line appears every 10 seconds):
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 1609 6565 13230 0 0 88 195 17 178 44 10 45 1 0
1 0 0 1599 6565 13232 0 0 0 226 4621 18688 22 6 72 0 0
4 0 0 1566 6565 13234 0 0 0 67 5217 20819 27 7 65 1 0
2 0 0 1533 6566 13241 0 0 0 847 6021 23359 35 6 58 0 0
The fields you want to watch are swap
si
and so
which means number of megabytes in 10 second period that are swapped in (from swap device to RAM) or swapped out. Usually the so
does not matter for system speed but si
will cause slowness and is caused by system having too small RAM for the processes that you're trying to run in paraller. The possible solutions are (1) close one or more applications that you're using, or (2) get more physical RAM.
Press Ctrl+C to exit vmstat
.
Note that vmstat
is not able to tell if system goes near zero free memory for short moments so free
, buff
and cache
may have big numbers even if memory is slow. sar
is probably the only program that can tell for sure if your memory is running out but that program is pretty hard to configure (not impossible, though - just install it and start with man sar
).
answered 9 hours ago
Mikko RantalainenMikko Rantalainen
554514
554514
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f756391%2fdo-i-need-to-clear-out-swap-to-make-my-computer-fast-again%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of How do I clean or disable the memory cache?
– Sergiy Kolodyazhnyy
Apr 11 '16 at 22:51
@Serg, not a duplicate.. at least of that question.
– psusi
Apr 11 '16 at 23:28