# releasing of RAM - gwenview, gimp

## stegerpl

Hi,

Since I have 4 GB of installed RAM I never thought to run in a problem with RAM so I disabled swap. However two weeks ago I figured out some effects when dealing with large photos (panoramas with 7 images each 2-3 MB). So I activated swap with 5 GB and added a free memory indication to one of my superkaramba themes.

Now I can see that when I work with gwenview (an image-viewer of KDE) as well as GIMP the memory consumption reaches the physical limits and swap is activated (rarely). But when I close the images within the programs, the memory consumption does not reduce. Even when I close the programs the memory consumption goes down to only about 3 GB and does not go back to about 1,5 GB which seems to be the normal consumption in my system.

Any hints where I can tune the release of memory ?

Is there a kernel feature which has to be activated ?

Any further information where I should have a look ?

Please post also which information you will need to help me - I do not want to post huge lists of useless information.

Peter

----------

## Ant P.

What does `free -m` output?

----------

## stegerpl

Hi, 

I just edited some images (max. RAM consumption about 3,5 GB) and made some outputs: one before I opened gwenview and GIMP, one after I closed them again (the last one) and four during working:

```
minbar rystall # free -m

             total       used       free     shared    buffers     cached

Mem:          3714        844       2870          0         52        323

-/+ buffers/cache:        467       3246

Swap:         5067          0       5067

minbar rystall # free -m

             total       used       free     shared    buffers     cached

Mem:          3714       1749       1964          0         56        577

-/+ buffers/cache:       1116       2598

Swap:         5067          0       5067

minbar rystall # free -m

             total       used       free     shared    buffers     cached

Mem:          3714       1907       1806          0         58        748

-/+ buffers/cache:       1101       2613

Swap:         5067          0       5067

minbar rystall # free -m

             total       used       free     shared    buffers     cached

Mem:          3714       3044        669          0         60        921

-/+ buffers/cache:       2062       1652

Swap:         5067          0       5067

minbar rystall # free -m

             total       used       free     shared    buffers     cached

Mem:          3714       2217       1496          0         61        957

-/+ buffers/cache:       1198       2515

Swap:         5067          0       5067

minbar rystall # free -m

             total       used       free     shared    buffers     cached

Mem:          3714       1540       2173          0         61        965

-/+ buffers/cache:        513       3200

Swap:         5067          0       5067
```

I feel it fills the cache - but I do not know when it should free them again...

Peter

----------

## DirtyHairy

Not sure what's supposed to be wrong with this output. The second number in the "+/- buffers/cache" line gives you the amount of memory which is available, including the memory the kernel currently uses as I/O cache.  Between the last free and the first one, this only differs by some 40MB (which has been supposedly claimed by some other, unrelated process(es)), so this looks fine for me. It's OK if you see less memory available in the "Mem:" line; the kernel will release buffers as needed.

----------

## stegerpl

Hi,

In this example the effect is not as dramatic as it shows up at other days. 

However, The system was rebooted when I made the first snapshot => 844 MB used.

Then I started the applications and after I closed both of them again I took the last snapshot => 1540 MB used

The difference is 696 MB. I can not estimate where they have gone, because it should be (almost) the same situation as before I started the applications.

OK I agree that applications might "waste" some memory or the system will keep some data in caches, but almost 700 MB ?!

On other days this amount reached almost 1.5 GB.

On the other hand I can read that the cached memory increased by 642 MB - that's almost what I am missing. 

Maybe I am misreading the information.

Peter

----------

## gerard27

Hi stegerpl,

Have you ever noticed the following:

The first time you start an application it takes a certain amount of time before it runs.

You close it and a little while later you start it again and then it starts almost immediately?

I'm no expert at this but I am sure that the application remains in RAM hence the quick restart.

When you don't restart it and the system needs RAM for something else the memory will be freed.

The fact that your swap is barely used proves this.

I have 4G RAM too and deleted swap because it was never used.

Gerard.

----------

## DirtyHairy

 *Quote:*   

> On the other hand I can read that the cached memory increased by 642 MB - that's almost what I am missing. 
> 
> Maybe I am misreading the information.

 

Yep, you are  :Smile:  Looking at the free memory without taking the buffers into account is close to meaningless. The kernel automatically allocates memory for buffers which it frees if it is needed. As gerard82 points out, if you read data from disk, the kernel will keep it in memory until the space it occupies is needed otherwise. This is desired behavior which dramatically speeds up your system in everyday use. The buffers line in the "free" output shows you how much memory is allocated to this kind of cache, and this memory is virtually "as-good-as-free".

----------

## drescherjm

 *stegerpl wrote:*   

> Hi,
> 
> In this example the effect is not as dramatic as it shows up at other days. 
> 
> However, The system was rebooted when I made the first snapshot => 844 MB used.
> ...

 

No the difference is 513 - 467 or 46 Mib

 *Quote:*   

> 
> 
> Maybe I am misreading the information.
> 
> 

 

You are reading the wrong line. Ignore the first line and only read the -/+ buffers/cache: line as the other user said.

Here is one of my file servers at work that has an uptime of 82 days

```
datastore2 ~ # uptime

 13:44:33 up 82 days, 48 min,  1 user,  load average: 0.10, 0.17, 0.17

datastore2 ~ # free -m

             total       used       free     shared    buffers     cached

Mem:          7460       7419         41          0          0       6746

-/+ buffers/cache:        672       6787

Swap:         4329          0       4329

```

This output tells me out of the 8GB of ram (which 7.4GB are usable)  672 MiB is in use. And ~6.7 GiB is file cache.

----------

## eccerr0r

 *drescherjm wrote:*   

> This output tells me out of the 8GB of ram (which 7.4GB are usable)  672 MiB is in use. And ~6.7 GiB is file cache.

 

Curious what chipset you're using, seems like this is not an Intel enterprise server chipset as they should be able to address all 8G plus io... Is it perhaps like a G965 or P43 or something in that caliber?  (Well, bad assumption of it being Intel, could be AMD or Sun or something too I guess.)

----------

## drescherjm

This is a desktop ASUS AM2 M2N board that is over 3 years old. The chipset is nForce4 but since the AMD CPU has the memory controller inside I do not believe the fault is with the nforce. Generally now all of our new file servers are $700 dual or quad core desktops with 8 to 10 harddrives using linux software raid 5 or 6.

Actually my XP 64 desktop that I am typing on now has the same mobo and cpu and it says is using all 8GB. I am not sure of the reason why I do not get all the ram under x86_64.

----------

