Linux (the kernel) is very good at freeing resources when programs exit. GNU/Linux, the entire OS, is generally fine to run indefinitely. Restarting user-space programs after you update them is generally a good idea, and often the easiest way to get everything using an updated glibc
is to reboot the system.
On systems with driver bugs (typically graphics driver bugs, everything else is usually rock solid), you sometimes get weird behaviour that gets weirder if you don't reboot soon. If you see a kernel OOPS in your dmesg
output, you should reboot as soon as is convenient, and report it (or google around for other people with similar problems on similar hardware, in case it's a known problem). Distros don't ship the very latest dev versions of the graphics stack, so sometimes the bug is already fixed upstream, and your graphics card is just too new for the drivers on the distro version you're running to be stable. In that case, look for a PPA with updated builds of mesa/drm/xorg. (I'm not sure what the best choice for running Ubuntu with a bleeding edge graphics stack is ATM).
Anyway, barring driver or other kernel bugs, Linux can run indefinitely without needing a reboot to clear memory fragmentation or anything like that.
I have a Linux router/firewall/mailserver/shell box (P3 450MHz, OCed to 500MHz) which routinely sees uptimes of hundreds of days. I reboot only to rearrange power cords, or to replace a failing power supply. It's been going steady with the same CPU/RAM/hard drives for probably 15 years. I've never had to reboot "because it was getting unstable". It was always for a specific reason, like failing power supply, or kernel upgrade, or power outage and my UPS battery was almost drained (triggering auto shutdown with apcupsd
).
If your system is acting weird, check dmesg
for problems. If it's just your desktop, then if you just installed some non-kernel package updates, log out / log in (or reboot, but you don't have to). I've found Kubuntu 15.04 will easily run into problems after package updates, I think due to binary incompatibility between upgraded / non-upgraded versions of the same library running in the same binary. (See discussion on this bug).
My go-to for checking for hardware problems is to boot memtest86+. (aptitude install memtest86+
) Let that run a full pass, or run overnight. That doesn't guarantee a stable system, since power supply voltage dips on spike loads can happen with CPUs these days, and memtest won't rule that out. Nor will it get your CPU hot, like Prime95.