Is there any application or command that cleans the memory like CCleaner in Windows?

1 Foreword

It's a bit strange that your system gets sightly slower after 8 hours. Since you also face the same problem on windows I guess this may be a hardware issue.

Without more information it is hard to say, but if you are lucky a RAM upgrade may help. If not, you maybe have to face a bigger hardware problem in the future.

2 Definitions and Distictions

RAM, temp-files, system-files and prefetch are different things.

  • On Linux systems you don't need RAM cleaners.

    If a process uses "too much" RAM stop and restart it. Such memory-leaking programs are often browsers and browser plug-ins. I also saw X.org misbehaving sometimes.

  • Temporary files only use some storage. So they won't slow down your system.

  • There is a reason why they are called system files. Most of them are used to run your system and programs like you are used to it. So if you don't know what you are doing, don't mess around with them!

  • Prefetching is Windows-specific. The Linux or Ubuntu equivalent is called (u)readahead.

    You don't have to think about it on Linux systems.

3 Software Recommendations

  • I recommend BleachBit: It's a good file-cleaner and (also in root-mode) you can hardly mess up your system.

    To install it open your terminal and type

    sudo apt-get update
    sudo apt-get install bleachbit
    

    type your password (no characters will be displayed) and wait till executed.

  • Till Ubuntu 12.04 you can use computer-janitor: But if you don't know what you are doing be careful. You may destroy your system!

    To install it open your terminal and type

    sudo apt-get update
    sudo apt-get install computer-janitor-gtk
    

    type your password (no characters will be displayed) and wait till executed.

  • Until Ubuntu 14.04 you can use Ubuntu Tweak: It has computer-janitor built in and many other more or less useful utilities. But as said before, be careful!

    To install it open your terminal and type

    sudo add-apt-repository ppa:tualatrix/ppa
    sudo apt-get update
    sudo apt-get install ubuntu-tweak
    

    type your password (no characters will be displayed) and wait till executed.


"Memory" and "temporary files" are different things.

Memory is normally RAM. Linux manages its RAM automatically, no cleaning needed; if there is some process misbehaving and using too much RAM, you just stop it. Browsers are classical offenders there; I need to close mine (and restart) every couple of weeks. Gnome-shell is another well-known memory leaker.

For the file part, you can install Ubuntu Tweak and use the janitor module:

Ubuntu Tweak Janitor

See also How safe is Ubuntu tweak's Janitor?. You can also install it using a PPA, look here in WebUpd8 (it's still ok for 14.04).

Consider anyway that if you clear a cache, the data will need to be reloaded/rebuilt, so the effect is, most of the time, to slow things down(1). For example, clearing the nautilus thumbnails means they are to be rebuilt again --- slowing down file browsing.

(1) the only exception here is the apt-cache and the old kernels --- in normal condition, on desktop, they are almost always just lost space.

If your system is really slowing down a "rogue" or leaking application is the most common reason. Try to catch it with top or similar tools, and if you find it, post a more specific question or a bug report.


You can free memory without installing more software by writing to the drop_caches file in the /proc/sys/vm directory.

First you will want to use a program like top or free to view the RAM usage and availability:

$ free -m
             total       used       free     shared    buffers     cached
Mem:         31730      31118        611      16606         57      25018
-/+ buffers/cache:       6042      25687
Swap:        32313          0      32313

Next you will need to execute the following command:

sudo sysctl vm.drop_caches=3

(which is roughly equivalent to the slightly more cumbersome sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'.)

Then run the free command and review the output:

$ free -m
             total       used       free     shared    buffers     cached
Mem:         31730       6224      25505        121          2        518
-/+ buffers/cache:       5702      26027
Swap:        32313          0      32313

Below are links to article that identify the process and documentation regarding the use of the drop_caches file.


Sources and further reading:

  • How to Free up RAM On Ubuntu/Debian
  • Documentation of /proc/sys/vm.