Memory management

When I first start an application, like Firefox it loads a lot of stuff from hard and starts slowly, but second time, startup is fast, because the required libraries are kept in memory. It is cool.

But … when I close firefox and start browsing my pictures, watch a movie, listen to music,or do anything else and not use firefox for, say, an hour, and after that start firefox, the startup is slow again. I guess the libraries loaded in memory cache are replaced with the other files I worked with.

Now the big question: it is a way to force linux to keep some libraries in memory cache? - for example firefox and the libraries it needs - to have always quick startup for certain applications.
I have 2gig rams, I use kde4.4 on opensuse 11.3,the applications I use most often are firefox, gwenview,konsole and dolphin.

Sorry for my english, I hope I wasn’t too confusing, and somebody can help me with this. Thank you!

First off, lets just confirm your statement that you are using openSUSE 11.3?!

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There is a tradeoff here that you are probably experiencing. The Linux
kernel has always been smart about memory use when nothing needs it which
leads to why it caches files from the disk so well. If you open something
its files are kept in ram (you can see how much is there using the free
command under the ‘cached’ column) so that subsequent requests go to RAM
(nanoseconds) instead of disk (milliseconds) so things are nice and
snappy. The nice thing about disk cached in RAM is that it is optional
and done just to improve performance so as soon as you open somtehing else
that NEEDS RAM (rather than something that happens to simply benefit from
the kernel’s efficient use of it) then clearing out cached data to free
space for another need is instantaneous so that you do not feel slowness
during that flush. If you had something KEEPING that RAM full time then
whatever else needs it will not have it and will be slower. Either you
will feel the slowness while your browser is closed with other apps (if
you can get the kernel to cache some files permanently) or you will feel
it when reloading the application that is no longer cached, as you do now.
If you want to feel neither (except for the first-time load of
applications as you mentioned) then you need enough RAM to both hold
everything from old apps as well ass anything new that comes up. I do not
see how else you could do that, though.

Good luck.

On 06/05/2010 09:56 AM, inp3dance wrote:
>
> When I first start an application, like Firefox it loads a lot of stuff
> from hard and starts slowly, but second time, startup is fast, because
> the required libraries are kept in memory. It is cool.
>
> But … when I close firefox and start browsing my pictures, watch a
> movie, listen to music,or do anything else and not use firefox for, say,
> an hour, and after that start firefox, the startup is slow again. I
> guess the libraries loaded in memory cache are replaced with the other
> files I worked with.
>
> Now the big question: it is a way to force linux to keep some libraries
> in memory cache? - for example firefox and the libraries it needs - to
> have always quick startup for certain applications.
> I have 2gig rams, I use kde4.4 on opensuse 11.3,the applications I use
> most often are firefox, gwenview,konsole and dolphin.
>
> Sorry for my english, I hope I wasn’t too confusing, and somebody can
> help me with this. Thank you!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMCoZtAAoJEF+XTK08PnB5ubQP/2n6iyB5OaJ2Yzk70lR1Fnws
DjFCOD0MGnjiT1zyhGtWWfAP+tbS/u+Lrd2u0+tGt668BZ6sHP6zXNCpgihJSeY1
ab1S8EqYl7vsum1Siks7pDjRrKJsGp6NDu9r+2eiXjOzPlRkxPBEo+juQGy6mYlA
Tuxz2IqlRSDznR0VWxKeCSwT5DWWSQHHIwbyWpym29Z55p9cYUMA0ix+TF9Bk8EX
6Z6E/XbXdo65xH9xbBwh88/p/c9cDfcpIdU/bWmJbOHL+4lssqj3TKKmymWvpJFo
h1CdoHRYMrRbwBv5RP3nxGKfEoznasbk6ma5w5Ugq2kCSL0dl4hrXsYhz89EHUqA
FhzSKFSuYgWdeanMvi49xkoYUnTnqkOGK3xsYxUp4FDRuNqFHdTKeacHnlARa87s
ScXqUNGiDZlejLDRZmJp4TOBqTmkmAJl/+J8QLj0w2CqXbx/h9wWiWYvTkyzqxHH
UenBMsu1iZS42cnHuRKi0BA+BDWFQHCdQervx9pbquUEm5n5QkgfoJPezDga27ec
PJkPnMIvTAohKEbS84xFPRp6zdm1/JbnsS4bM7z+v1BJfPBkk5TJ8nO3YgjG8SSy
RBaWq1JDIfsZAo9MTCKL7Py/7vAZQVbH6xSMCM4qOhOU4onafRBlc1U0CJ4Bt7Rk
We9rqsbL/wHAU5dlnelK
=/lWi
-----END PGP SIGNATURE-----

caf4926: Yes, I am using opensuse 11.3 Milestone 7.

ab@novell.com:
I have 2GB ram,I think that should be enough. Let me explain again what I was thinking about and correct me, if I know things wrong.

Let’s consider the following scenario:

Let’s say that I need 1Gb memory for kde and all the applications I run. So remains 1Gb for file cache. I start firefox, all the libraries loaded are cached in memory, that will occupy 200Mb more ram. So it will remain 800mb to cache more files.
Then I close firefox and listen some music while I sort the downloads folder. All the music I listen and all the files I move or copy from downloads will be cached in memory. So when the remaining 800Mb fills up, the kernel clears the firefox libraries from cache and fill it up with mp3s.
So I will have 1Gb of cached mp3-s and when I start firefox again, the libraries will be readed from the disk agan = slow firefox start.

So what I was thinking about is that if it is possible to tell the kernel to keep some files always in memory cache ( like, for example libraries needed by firefox ) and use less for memory other files.
It will be like an 512mb super fast drive from where firefox is loaded and 1.5Gb of system memory.

On 06/05/2010 02:36 PM, inp3dance wrote:
>
> caf4926: Yes, I am using opensuse 11.3 Milestone 7.
>
> ab@novell.com:
> I have 2GB ram,I think that should be enough. Let me explain again what
> I was thinking about and correct me, if I know things wrong.
>
> Let’s consider the following scenario:
>
> Let’s say that I need 1Gb memory for kde and all the applications I
> run. So remains 1Gb for file cache. I start firefox, all the libraries
> loaded are cached in memory, that will occupy 200Mb more ram. So it will
> remain 800mb to cache more files.
> Then I close firefox and listen some music while I sort the downloads
> folder. All the music I listen and all the files I move or copy from
> downloads will be cached in memory. So when the remaining 800Mb fills
> up, the kernel clears the firefox libraries from cache and fill it up
> with mp3s.
> So I will have 1Gb of cached mp3-s and when I start firefox again, the
> libraries will be readed from the disk agan = slow firefox start.
>
> So what I was thinking about is that if it is possible to tell the
> kernel to keep some files always in memory cache ( like, for example
> libraries needed by firefox ) and use less for memory other files.
> It will be like an 512mb super fast drive from where firefox is loaded
> and 1.5Gb of system memory.

Keep Firefox loaded. That will do what you want.