LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-08-2017, 07:05 AM   #1
Vivekanandan Dhamodharan
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Rep: Reputation: Disabled
Smile Linux Memory calculation related


Hi,


I have using Ubuntu 14.04 LTS linux machine.I have run more than one application in my system. I want to run additional application at that time my RAM is fully used after that continuously run another application in this time my system running good but memory is used to swap memory.so i want to one doubt how to i calculate my system total memory size? for example My RAM size is 8GB and swap memory is also allocated upto 8GB.

1.This total memory is RAM memory only or RAM+SWAP memory?

2.How to find the System memory size? and what is the main use of swap memory in linux?

Last edited by Vivekanandan Dhamodharan; 02-09-2017 at 03:39 AM.
 
Old 02-08-2017, 07:23 AM   #2
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
top will probably be the first port of call if you're using command line only. It will display CPU and memory statistics in itself and can be used to list processes by their actually %mem usage.

Swap is an expansion of the paging system on to another peripheral generally a hard drive but could be an SSD, a flash card or potentially a number of any other devices. By extending the paging to these devices it means lesser used memory can be shifted off of the paging on RAM to the paging on the SWAP device/file to free up RAM for other more important tasks. Swap has a cost associated to it's usage, if you swap too heavily or make swap too large then you will see decreased performance from it.

Last edited by r3sistance; 02-08-2017 at 07:24 AM.
 
Old 02-08-2017, 07:26 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
If you run "free" it will show you memory information.

Output would look similar to this:
total used free shared buffers cached
Mem: 2903116 2677956 225160 0 443788 1896044
-/+ buffers/cache: 338124 2564992
Swap: 5079032 148 5078884

Note that Linux pre-caches and buffers most of its memory so the "free" column on top line is the amount is based on that.
The line below that has what is actually "free" in that the pre-cached memory and buffers are easily reclaimed for use in other processes.

Swap in Linux as in UNIX these days is used more for "paging" than "swapping" meaning as memory pages age they get written to swap and on occasion may be read back from there. A system that is doing heavy reads from swap usually is under heavy memory pressure and you'll see performance issues. You should allocate swap to allow for normal aging writes and a low level of reads but if you're doing heavy reads you really need to increase RAM.

You can see more details of memory with vmstat, sar and in /proc/meminfo.
 
Old 02-08-2017, 08:09 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Also: cat /proc/meminfo.

The /proc "directory" is actually an operating-system API where lots of important information can be found. While it all appears to be "files" and "directories," it's actually all a figment of the operating system's imagination.

If you are running memory-intensive applications, you need to know that you have enough physical RAM to accommodate all of them. ("Splurge. Buy more. Chips are Cheap.™")

You need to plan the purchase of resources against the needs of the application-mix that you intend to run.

You can use commands such as ulimit to impose limits upon an application, e.g. how much memory it is permitted to allocate. But you must be sure that the application is actually prepared to handle being denied a request to obtain memory. If the application has configuration-file controls which inform it of limits that it is expected to honor, first use those controls, then perhaps use ulimit to give them teeth.

"Swapping" uses disk space as an adjunct for RAM, and it is always expensive since the application comes to a dead stop while the so-called "page fault" is being resolved. Furthermore, swapping becomes a very substantial load on the disk-I/O subsystems of the computer, in addition to (and usually, pre-empting) ordinary application disk traffic. In these days and times, when RAM is cheap and plentiful, it is a thing to be avoided.

---
Incidentally, you will observe that Linux will use all available RAM for some purpose, such as "file buffers" if nothing else. RAM is a resource that is "there to be used," and all of it will be used for something.

Last edited by sundialsvcs; 02-08-2017 at 08:12 AM.
 
Old 02-08-2017, 10:23 PM   #5
Vivekanandan Dhamodharan
LQ Newbie
 
Registered: Jun 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MensaWater View Post
If you run "free" it will show you memory information.

Output would look similar to this:
total used free shared buffers cached
Mem: 2903116 2677956 225160 0 443788 1896044
-/+ buffers/cache: 338124 2564992
Swap: 5079032 148 5078884

Note that Linux pre-caches and buffers most of its memory so the "free" column on top line is the amount is based on that.
The line below that has what is actually "free" in that the pre-cached memory and buffers are easily reclaimed for use in other processes.

Swap in Linux as in UNIX these days is used more for "paging" than "swapping" meaning as memory pages age they get written to swap and on occasion may be read back from there. A system that is doing heavy reads from swap usually is under heavy memory pressure and you'll see performance issues. You should allocate swap to allow for normal aging writes and a low level of reads but if you're doing heavy reads you really need to increase RAM.

You can see more details of memory with vmstat, sar and in /proc/meminfo.



It's ok, but the system memory consider with RAM memory only or RAM+SWAP memory. Please explain clearly
 
Old 02-09-2017, 12:20 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
probably you need to read: www.linuxatemyram.com
 
1 members found this post helpful.
Old 02-09-2017, 08:46 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Let's briefly talk about what "swap" is. To do that, we must discuss what "virtual memory" is.

Every process that is running has its own so-called "address space." This is its view of what "memory" contains. But you could have 100 different processes out there, all with a different notion of "what's in memory-location $12345678." They can do this because it is virtual memory.

Physically, memory is divided into equal-sized units called "pages," and the virtual-memory hardware in the CPU translates the addresses issued by the program ("$12345678") into some other address that is actually sent to the memory chips. Processes don't see this happening, but this is why each of them can have an entirely different notion of "what's in location $12345678." Each of them is subject to a different virtual-address-to-physical-address mapping, courtesy of the hardware (which they never perceive).

The data for any given page, for any given process, can be "anywhere in RAM," or "not in RAM!" The data might have been removed from RAM and swapped out to disk. When (and if) the process references that page again, a page fault interrupt will be generated by the CPU, and Linux will swap in the data from disk again. (After possibly swapping-out some other page to make room.)

Linux will always use all of physical RAM for some purpose. Virtual-memory "page frames" are only one possible use. If nothing else, Linux will use RAM for file-system buffers, pre-reading data from a disk file and stashing it in memory in anticipation of near-future use. As memory-load manifests itself, Linux has various priorities for how RAM will be used. (And, in cases of extreme unction, there is also the dreaded "OOM Killer" – "OOM == Out Of Memory." Yes, to save itself, Linux will start killing processes.)

Last edited by sundialsvcs; 02-09-2017 at 05:56 PM.
 
Old 02-09-2017, 09:39 AM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Moderator Response

Please post a single post for your problem to avoid problems/confusion. Your other thread has been closed; http://www.linuxquestions.org/questi...am-4175599353/
 
Old 02-09-2017, 10:02 AM   #9
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Quote:
Originally Posted by Vivekanandan Dhamodharan View Post
Please explain clearly
That's the kind of thing that is most likely to prevent me trying to help you further. I responded to the question as you initially asked it. If my response wasn't helpful then you didn't ask the question you meant and should rephrase or ask a new question based on the responses you got.
 
Old 02-09-2017, 10:34 AM   #10
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,806

Rep: Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207Reputation: 1207
Hint: always have some swap, even half a GB helps Linux if there is memory pressure.
Linux cashes all it finds, thus maneuvers itself near a memory pressure situtation.

Regarding monitoring, everybody asks how to measure RAM and swap usage separately.
However it is impossible to find good alert thresholds.
Monitoring RAM+swap makes more sense.
That's one of the reasons I wrote my own Nagios plugins. Extract the check_vmem.sh that measures RAM+swap usage. (And makes a rough assumption of cache availability.)
 
Old 02-09-2017, 12:38 PM   #11
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,672

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by MensaWater View Post
That's the kind of thing that is most likely to prevent me trying to help you further. I responded to the question as you initially asked it. If my response wasn't helpful then you didn't ask the question you meant and should rephrase or ask a new question based on the responses you got.
And that's the kind of thing that makes me think "Gee, this is a homework question"....
 
Old 02-09-2017, 09:47 PM   #12
Crippled
Member
 
Registered: Sep 2015
Distribution: MX Linux 21.3 Xfce
Posts: 595

Rep: Reputation: Disabled
Quote:
Originally Posted by Vivekanandan Dhamodharan View Post
Hi,


I have using Ubuntu 14.04 LTS linux machine.I have run more than one application in my system. I want to run additional application at that time my RAM is fully used after that continuously run another application in this time my system running good but memory is used to swap memory.so i want to one doubt how to i calculate my system total memory size? for example My RAM size is 8GB and swap memory is also allocated upto 8GB.

1.This total memory is RAM memory only or RAM+SWAP memory?

2.How to find the System memory size? and what is the main use of swap memory in linux?
You have something wrong if you run out of 8GB of ram. I have 8GB ram also and I do more than that and have at least 2GB ram to spare.
 
Old 02-12-2017, 06:35 PM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
[list][*] "Applications" are not created equal ... and-d-d-d ...[*] "It's only 'ones and zeros,' kid!" Das Komputenmachin is [only] just that: a machine.

If you tried to lift the Statue of Liberty using your tow-truck, and your truck fell into New York Harbor in the process of trying your stupid stunt, then you would have only yourself to blame for those millions of 'tweets' and mocking YouTube videos.

You have to be aware of exactly what it is you are asking your Das Komputenmachin to do, and of the resource-requirements needed to do it effectively and successfully. You need to be sure that the machine in question has the necessary hardware resources. No one else can do this for you.

- - -
However, if you have a particular situation that you need help with, such that you think that someone else here might also have encountered it, then please give us more details about your particular situation and requirements. I do not intend my post here to be a "shut-up and go-away" rebuttal. Not at all. Not at all ...

Last edited by sundialsvcs; 02-12-2017 at 06:39 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
memory calculation sang_froid Linux - Server 1 03-21-2011 01:24 PM
memory calculation mario.almeida Linux - Server 3 07-22-2010 10:05 AM
TOP command: calculation of memory usage samiralmousawi Linux - Server 7 07-29-2008 03:16 PM
Virtual Memory Related ramkumarv Linux - General 1 03-20-2006 07:09 AM
Not really Linux related memory question Aerlock Linux - Hardware 2 10-18-2003 08:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration