LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-25-2010, 10:50 PM   #1
kresyzig
LQ Newbie
 
Registered: Aug 2010
Posts: 10

Rep: Reputation: 0
Question Total amount of allocated SHM memory?


Is there an easy way in C to get the total amount of allocated SHM memory on a machine?
 
Old 08-26-2010, 03:57 PM   #2
Kenny_Strawn
Senior Member
 
Registered: Feb 2010
Location: /usa/ca/orange_county/lake_forest
Distribution: ArchBang, Google Android 2.1 + Motoblur (on Motortola Flipside), Google Chrome OS (on Cr-48)
Posts: 1,791
Blog Entries: 62

Rep: Reputation: 54
It would probably be C's equivalent to the following shell command:

Code:
cat /dev/shm
 
Old 08-26-2010, 05:03 PM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Kenny_Strawn View Post
It would probably be C's equivalent to the following shell command:

Code:
cat /dev/shm
?????

Code:
file /dev/shm
/dev/shm: sticky directory
 
Old 08-26-2010, 05:11 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
man 2 shmctl
 
Old 08-27-2010, 07:05 AM   #5
kresyzig
LQ Newbie
 
Registered: Aug 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Sergei Steshenko View Post
man 2 shmctl
This is what I was looking for. Thanks!
 
Old 08-27-2010, 05:33 PM   #6
kresyzig
LQ Newbie
 
Registered: Aug 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Question

Quote:
Originally Posted by Sergei Steshenko View Post
man 2 shmctl
Sorry this does not work. shmctl recognizes only System V shared memory and I am working with POSIX shm... Is there anything equivalent for POSIX shm?
 
Old 08-27-2010, 06:02 PM   #7
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by kresyzig View Post
Sorry this does not work. shmctl recognizes only System V shared memory and I am working with POSIX shm... Is there anything equivalent for POSIX shm?
Maybe
http://www.cs.cf.ac.uk/Dave/C/node27...00000000000000 .
 
Old 08-28-2010, 02:34 AM   #8
kresyzig
LQ Newbie
 
Registered: Aug 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Sergei Steshenko View Post
Finally I have used opendir("/dev/shm") combined with readdir_r to get the size of the pseudo-files in /dev/shm/ /. This is the only way I have found to compute the total amount of shared memory. That works fine, I just don't know if there is a more optimal method...
 
  


Reply

Tags
memory, shm


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
total free allocated file descriptors always zero Stephan_Craft Linux - Server 2 07-24-2010 11:36 AM
Does /dev/shm reduce memory available for non-shared memory segments? mightyscotchpine Linux - Server 1 09-22-2009 06:58 PM
Boot Hangs with Redhat, GRUB, Total HugeTLB memory allocated, Neochubbz Linux - General 5 08-19-2004 01:27 PM
shared Memory versus the total amount of RAM on the server ashley75 Linux - General 1 08-25-2003 11:21 AM
Limiting the total amount of memory usage by apache. SplashHost.com Linux - General 8 08-30-2002 09:56 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration