homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

how to monitor shared memory usage

 12:58 pm on Oct 8, 2007 (gmt 0)

Good Day to all.I just want to know is there any options to find the usage of my shared memory?that is it should display the used and leftout shared memory. (note: like free command for memory).
Please help me.Thanks in advance.




 3:49 pm on Oct 8, 2007 (gmt 0)

Normally, the amount of memory allocated for use by graphics is determined by a bios setting. For instance, the laptop I'm using right now seems to have allocated 128MB for graphics. I can deduce this from the fact that it has 1GB of memory (1024 MB) but it is only showing 894 MB of physical memory available to Windows. 2MB seems to have evaporated.



 3:52 pm on Oct 8, 2007 (gmt 0)

Exactly what do you mean by "shared memory"? It's an ambiguous term that can have many meanings.


 4:02 am on Oct 10, 2007 (gmt 0)

Hi jtara,
I am running ad server built using PHP on top of MySQL. It is designed to handle many hundreds of thousands of ad impressions per hour(oasis).OASIS utilizes a number of shared memory segments to facilitate rapid ad delivery and to cut down the number of queries made against the database.Now shared memory is created, i want to monitor the usage of shared memory(NOTE:like "free" command to find usage of ram memory).Is anyone having idea?please help me.

Thanks in advance.


 4:29 am on Oct 10, 2007 (gmt 0)

If this is a Linux system, you can display shared memory segments by using the command "ipcs -m" at a shell prompt.


 5:10 am on Oct 10, 2007 (gmt 0)

yes, it is a linux system and i want to display used and left out shared memory.


 6:06 am on Oct 10, 2007 (gmt 0)

yes, it is a linux system and i want to display used and left out shared memory.

Not sure what "left out" shared memory is...

Shared memory is, just... memory.

It's a chunk of memory that can be shared by multiple processes. An application acquires shared memory by making a system call similar to what it would make to acquire conventional memory. The only difference is that each chunk of shared memory has a name (or "key") and it's possible for another application to map the same shared memory, by referencing the key.

On modern operating systems, there's no specific shared-memory "pool". (Older versions of Windows had a limited pool of shared memory.) Any memory can be made into shared memory - it's just a matter of the OS flipping some bits that make it available to map-in to other processes. So, it's not a limited resource that is easily depleted. That is, it's no more precious than "normal" memory.

Under Linux, shared memory is backed by the swap partition. (As is "normal" memory.)

I doubt there's really much reason to monitor shared memory, outside of curiosity.

Note that it's fairly difficult to interpret Linux memory statistics. A casual observation will suggest that almost all Linux systems are deficient of free memory. This is because the OS tries to allocate any unused memory to cache and tmpfs. When memory is needed for other purposes, it's withdrawn from these uses.


 8:30 am on Oct 10, 2007 (gmt 0)

Thanks a lot for your effort on this.
In my server we are creating shared memory segment and semaphore via php script.we are specifying the size of each segment also.now we are getting error of not-enough space on shared memory from application.when we are checking the ads all are occupying only 50% of alloted size.so we want to check the used and left out shared memory.Is there any tool or script to do that? Please help me


 3:45 pm on Oct 10, 2007 (gmt 0)

(This post should probably be moved to the Linux/Unix forum.)

As I suggested before, "ipcs -m" will display the shared-memory segments currently in use.

Perhaps this will help you debug your application.

Still not sure what you mean by "used or left out".

The OS doesn't know how much of a shared-memory segment has been "used". Your app makes a call, say, asking for a shared-memory segment of 10,000 bytes. At some point you tell the OS you are done, and it takes the memory back. But the OS has no idea if you've stuffed 1 byte, 5000, or 10,000 into the memory.

Should you attempt to write outside of an allocated memory segment (e.g. in the above example, to byte 10,001) you will get a segmentation violation.

You *are* giving the shared memory segments back eventually, right? ;)

It's unclear to me if you've written this application yourself, or if it is a software package you've obtained. If it's a software package that you didn't write yourself, you're probably best off seeking help from any support resources that application has. Sounds more to me like a buggy program than an actual OS problem.

Now, there are some limits placed on shared memory segment size, number of shared memory segments, etc. This varies from system to system. There are a number of kernel variables that you can view to determine the limits on your system. You can "cat" the variable numbers in /proc/sys/kernel. For example, to view the maximum size of a shared-memory segment:

cat /proc/sys/kernel/shmmax

Here are the values on my Fedora Core 6 system:

shmmax - max size of a shared-memory segment: 33554432

shmall - total shared memory avail: 2097152

shmseg - max # of shared memory segs per process: (doesn't exist in FC6)

shmmni - max # of shared memory segs system-wide: 4096

Note my previous caveat about interpreting "available memory" statistics in Linux. They aren't really meaningful, as you need to add the memory being used for disk caching and tmpfs to any "available" feature.

I'm thinking your app may be running afoul of the max number of shared memory segments system-wide - especially if it isn't giving them back when it is done!


 9:11 am on Oct 12, 2007 (gmt 0)

Thanks jtara.Really, you are so informatic.Thanks a lot again for all your replies.It may be application fault i should check on this.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved