Kernel Newbies archive on lore.kernel.org
 help / color / Atom feed
* Free RAM in Linux .
@ 2019-12-17  5:09 Neel chakraborty
  2019-12-17  6:29 ` Valdis Klētnieks
  0 siblings, 1 reply; 2+ messages in thread
From: Neel chakraborty @ 2019-12-17  5:09 UTC (permalink / raw)
  To: kernelnewbies

[-- Attachment #1.1: Type: text/plain, Size: 1064 bytes --]

I was studying the Linux Kernel Source , and came across this doubt .

Does Linux use all of the physical memory (RAM) I have ? In both the
outputs of /proc/meminfo and free -h , shows that 1.4 gigs is used and 1.6
gigs is cached , and the rest is "free" out of 32 Gigs . The available ram
is the cached ram + reclaimable ram + free ram , right ?

I went through the source code of /fs/proc/meminfo.c and it's polling ram
usage from the sysinfo struct , so I browsed through
/linux/include/uapi/Linux/sysinfo.h , over there freeram is available
memory size .

But again in meminfo.c , we are seeing MemFree as i.freeram ( here i is
assigned to the structure of type sysinfo ) .

so is free ram = available memory ? But then , I have free ram of 27 Gi ,
and available memory of 28 Gi , why is that ?

And also , does the linux kernel use the amount of ram which is not used by
applications as paging cache ? Say I have 4 gigs of ram , and Firefox is
using 1 gig of it , the rest of RAM is used for disk/page caching or is it
just unused and left there ?

Thank you

[-- Attachment #1.2: Type: text/html, Size: 1432 bytes --]

<div dir="ltr"><p><span style="color:rgb(0,0,0)"> I was studying the Linux Kernel Source , and came across this doubt .<br></span></p><p><span style="color:rgb(0,0,0)">Does
 Linux use all of the physical memory (RAM) I have ? In both the outputs
 of /proc/meminfo and free -h , shows that 1.4 gigs is used and 1.6 gigs
 is cached , and the rest is &quot;free&quot; out of 32 Gigs . The available ram 
is the cached ram + reclaimable ram + free ram , right   ?</span></p><p><span style="color:rgb(0,0,0)">I
 went through the source code of /fs/proc/meminfo.c and it&#39;s polling ram
 usage from the sysinfo struct , so I browsed through 
/linux/include/uapi/Linux/sysinfo.h , over there freeram is available 
memory size .</span></p><p><span style="color:rgb(0,0,0)">But again in meminfo.c , we are seeing MemFree as i.freeram ( here i is assigned to the structure of type sysinfo ) .</span></p><p><span style="color:rgb(0,0,0)">so is free ram = available memory ? But then , I have free ram of 27 Gi , and available memory of 28 Gi , why is that ?</span></p><p><span style="color:rgb(0,0,0)">And
 also , does the linux kernel use the amount of ram which is not used by
 applications as paging cache ? Say I have 4 gigs of ram , and Firefox 
is using 1 gig of it , the rest of RAM is used for disk/page caching or is it just unused and left there ?</span></p><p><span style="color:rgb(0,0,0)">Thank you</span></p></div>

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Free RAM in Linux .
  2019-12-17  5:09 Free RAM in Linux Neel chakraborty
@ 2019-12-17  6:29 ` Valdis Klētnieks
  0 siblings, 0 replies; 2+ messages in thread
From: Valdis Klētnieks @ 2019-12-17  6:29 UTC (permalink / raw)
  To: Neel chakraborty; +Cc: kernelnewbies

[-- Attachment #1.1: Type: text/plain, Size: 1307 bytes --]

On Tue, 17 Dec 2019 10:39:08 +0530, Neel chakraborty said:

> Does Linux use all of the physical memory (RAM) I have ? In both the
> outputs of /proc/meminfo and free -h , shows that 1.4 gigs is used and 1.6
> gigs is cached , and the rest is "free" out of 32 Gigs . The available ram
> is the cached ram + reclaimable ram + free ram , right ?

That probably means that the processes you have running use a total
of 1.4G of ram, and you've referenced 1.6G of files on disk.

The rest is free because you've not done anything to give the system even
a hint of what to do with the other 27G of RAM.

If you reference a whole bunch of files (find /usr -type f | xargs cat) > /dev/null
or other similar), you'll see more gigs used for cache.

If you run a few large processes, like a Chrome with 90 tabs open, you'll
see the other number go up.

> And also , does the linux kernel use the amount of ram which is not used by
> applications as paging cache ? Say I have 4 gigs of ram , and Firefox is
> using 1 gig of it , the rest of RAM is used for disk/page caching or is it
> just unused and left there ?

The kernel itself will use some of it, other processes will use some of it, and
if there's any left, it will be used for disk caching - but not until a process
has actually referenced data off the disk.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17  5:09 Free RAM in Linux Neel chakraborty
2019-12-17  6:29 ` Valdis Klētnieks

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git