Reply to topic

KDE uses up a lot of memory, or I just don't understand it.

Terces
Registered Member
Posts
6
Karma
0
OS
Hey there,

I've been having the problem of KDE using up way too much memory. I know not all of the memory really is used, but the command free -m gave me following output:
Code: Select all
              total        used        free      shared  buff/cache   available
Mem:           7981        2000        4142         114        1838        5566
Swap:         10239          46       10193


I get to this point having just done some light PC usage, such a browsing a bit and open some folders and one or two documents. I know a lot is cached for possible future use, but I also noticed that if I was to start a memory intensive program now (modded minecraft for example), a lot of data is pushed into the swap area. Starting the game fresh after boot (OS "only" uses around 800MB), that does not happen.

Basically what I want to know: Why is it, that I have no problem running the game after a fresh boot, but run into problems after having opened some programs? Shouldn't the cache be dropped as soon as a different program requires memory? Isn't the cache purged every now and then?
compatico
Registered Member
Posts
89
Karma
0
OS
Terces wrote:Hey there,

I've been having the problem of KDE using up way too much memory. I know not all of the memory really is used, but the command free -m gave me following output:
Code: Select all
              total        used        free      shared  buff/cache   available
Mem:           7981        2000        4142         114        1838        5566
Swap:         10239          46       10193


I get to this point having just done some light PC usage, such a browsing a bit and open some folders and one or two documents. I know a lot is cached for possible future use, but I also noticed that if I was to start a memory intensive program now (modded minecraft for example), a lot of data is pushed into the swap area. Starting the game fresh after boot (OS "only" uses around 800MB), that does not happen.

Basically what I want to know: Why is it, that I have no problem running the game after a fresh boot, but run into problems after having opened some programs? Shouldn't the cache be dropped as soon as a different program requires memory? Isn't the cache purged every now and then?

First off, why do you have more swap than RAM? Linux looks at swap as memory and will take advantage of large amounts of swapfile. Unless you hibernate/suspend to disk, you don't need that much swap space, unless you want it for a specific reason. Without hibernate, you can run a smaller 1gig swapfile with 8gigs of RAM, unless you need more due to large data processing or hibernation.

The OS will assume that you want to keep some of that data available for future use and swaps it out. Most of the buff/cache you see is actually disk caching of previous data for quicker access of frequently used applications and data. This uses lots of memory which is a good thing, speeding up your system with less disk accesses. Unfortunately swapping is slow on a regular disk drive. If you use an SSD swapping is much faster, and so is loading of the new program data. If you don't have an SSD, i have to ask WHY THE HECK NOT?? ;D SSD's are cheap enough that you really should have one...they're so much faster than disk drives and you'll wonder why you didn't get one sooner.

Having said that, you can adjust how swapping occurs by using the swappiness control command and setting. With it you can drastically reduce swapping:

http://askubuntu.com/questions/103915/h ... swappiness

I have swappiness set to 1 to minimize it completely with a 512mb swapfile. With 32gigs of RAM I don't really need a swapfile and have actually run without one on 16gigs of RAM, but I have one just in case something goes amiss and I have enough room to spare for some swap space.
YMMV
NoNameNoBlame
Karma
0
Rule Nr. 1:
Never use swap-files.
Always use swap partitions.

Rule Nr. 2:
Make swap-partition double the size of physical RAM


Example:
Code: Select all
$ free -ghw
_________total_____used_____free____shared____buffers___cache___available
Mem:______7,8G_____2,0G_____3,2G_____32M______3,3M______2,5G_____5,4G
Swap:______16G_______0B______16G


# To the Original Poster:
You still have 5566MiB physical RAM available before swapping.
Seems enough for me.
compatico
Registered Member
Posts
89
Karma
0
OS
NoNameNoBlame wrote:Rule Nr. 1:
Never use swap-files.
Always use swap partitions.

Doesn't make any difference any more...a file or partition is essentially the same to the OS. In theory a partition could be faster due to less overhead, but we're talking nanoseconds that you would never notice in actual use.
Rule Nr. 2:
Make swap-partition double the size of physical RAM

Old info for ancient computers, and unnecessary with larger amounts of RAM. RAM is much cheaper today than it was years ago when disk space was much cheaper than RAM, hence the thought that lots of swap was good.

I have 32gigs in my current system...should I have a 64gig swap? Not a chance as I have enough RAM my swap doesn't get used. The more RAM you have, the less swap you need...once you hit about 6-8gig swap becomes less necessary. Swap is additional virtual memory storage for when you RUN OUT OF MEMORY SPACE in RAM. If you have lots of RAM, you simply don't need much swap (and can turn it off completely if not needed).

Here's a simple chart showing needed swap space:

1gig RAM - 2gig swap
2gig RAM - 2gig swap
4gig RAM - 1gig swap
8gig RAM - 1gig swap
16gig RAM - 512mb swap (or none)
32gig RAM - 512mb swap (or none)

You want to minimize swapping to a disk drive as it's very slow compared to memory, and the best way to do that is to have enough RAM to run your programs without needing to swap out pages. If you have an SSD then your drive is very fast and this is less of an issue. But you still want to minimize swapping with more RAM. Putting an SSD in a computer with only 1gig of RAM is a poor choice of resource improvements - spend the money on RAM instead.

NOTE - If you need to hibernate your system, then you need at least the same amount of swap as RAM to store the data on your disk while hibernating. So yes, if I needed to hibernate, I would need a 32gig swap space.
NoNameNoBlame
Karma
0
The reason for using swap-partitions is:

If You use a swap-file, You have to think about the filesystem-type:
"ext4"? "btrfs"? "zfs"? etc.?
Not all filesystem-types are good for swap-files.

With swap-partitions, You don't even have to think about such
possible problems.
compatico
Registered Member
Posts
89
Karma
0
OS
NoNameNoBlame wrote:The reason for using swap-partitions is:

If You use a swap-file, You have to think about the filesystem-type:
"ext4"? "btrfs"? "zfs"? etc.?
Not all filesystem-types are good for swap-files.

With swap-partitions, You don't even have to think about such
possible problems.

Sure, if you have the knowledge to know that you need or don't need hibernation and need a partition or not, then file system type becomes an issue if you stray from the norm and customize it your way. In that case you should know what you're doing.

But if you're new to Linux you're going to use the guided setup and create a swap partition the same size as your RAM making all of this moot.
Eneen
Registered Member
Posts
71
Karma
0
OS
Terces wrote:Hey there,

I've been having the problem of KDE using up way too much memory. I know not all of the memory really is used, but the command free -m gave me following output:
Code: Select all
              total        used        free      shared  buff/cache   available
Mem:           7981        2000        4142         114        1838        5566
Swap:         10239          46       10193


I get to this point having just done some light PC usage, such a browsing a bit and open some folders and one or two documents. I know a lot is cached for possible future use, but I also noticed that if I was to start a memory intensive program now (modded minecraft for example), a lot of data is pushed into the swap area. Starting the game fresh after boot (OS "only" uses around 800MB), that does not happen.

Basically what I want to know: Why is it, that I have no problem running the game after a fresh boot, but run into problems after having opened some programs? Shouldn't the cache be dropped as soon as a different program requires memory? Isn't the cache purged every now and then?


That's pretty weird, my neon is taking about 500M after boot with teamviewer installed. Without it's about 430M. It's fresh and clean install. I've checked quite few distros and neon ram usage is pretty low IMO.

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], freddylegen, Google [Bot], grahm, irvingarrietavazquez, Majestic-12 [Bot], nrykhe, paleo, rblackwell, Sogou [Bot]