Remi Wilde
Remi Wilde

Reputation: 33

Memory management when reading the same file over again

I am wondering if linux keeps something in memory (in order to speed up next time) when reading a text file over and over again ? I am not modifying the text file. Just reading.

Thanks !

Remi

Upvotes: 0

Views: 115

Answers (2)

Harald Brinkhof
Harald Brinkhof

Reputation: 4455

In a linux kernel, the read() system call loads your data in the page cache, if this data is still around next time your perform read() on the same location, then yes, it will read from this cache and speed up things.

you can read a bit up on it in this tutorial and just by researching it in google and other search engines.

Upvotes: 1

michel-slm
michel-slm

Reputation: 9756

Yes, the Linux kernel would allocate unused memory to buffering disk accesses (which is why if you use top you'd see that, under active usage, you normally don't see much free RAM)

Upvotes: 2

Related Questions