• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

about shared memory

Hi,

I am using shared memory. And I got some questions...

1. When a parent process has already attach the shared memory and fork a child, would the child inherite the shared memory segment??

2. I am running a program that I wrote using fork and shared memory. It compills okay and when I run, I get this message " No space left on device shared memory".
I have done some research and found out I can see how many shared memory currently exist. I typed in "ipcs -m" command line to see how many shared mem exist and found out there are so many!! (more than 50!!) IS there anyway that I can just delete existing shared memory??

Thank you for any advise~! And happy Thanksgiving!
0
shinymoon
Asked:
shinymoon
  • 2
  • 2
1 Solution
 
SwassLikeMeCommented:
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296

Customizing these for your system and adding them into the /etc/sysctl.conf file should make it work.  You'll need to reboot of course.

Yes, you can delete shared memory segments, but please make sure you're processes are no longer using them.  Do a 'man ipcs' to see how to do that.  Also, if your program isn't running anymore but still has hold of the shared memory, you'll need to make sure it gives it back to the operating system when it's finished running.  This will chew up memory allocation very quickly if you don't do that.
0
 
shinymoonAuthor Commented:
I opend /etc/sysctl.conf file to add those customizations. But, the file is read-olny file so that I could not modify anything........

In my program, I did not remove shared memory segments before ( now I added code to remove shared mem segment after I am done using)......And I guess the shared memory segments I've created still exist and used up the memory.....

What should I do??
please help. I need to pass my operating class......
0
 
SwassLikeMeCommented:
Sorry for the delay in responding.  I've been out of town for the Thanksgiving.  You'll need write permissions to the file otherwise it won't work.  If you are root, you automatically have the permissions, but you'll need to force them by doing a :w!  

Rebooting the box will clear the memory segments up that you have in place.  I wouldn't actually modify the sysctl.conf file if you don't need to -- and it sounds as though you don't need to.  But if you do choose to, please make sure you modify the parameters for your system -- they are based on memory, etc.  This can cause more problems for you if they are inappropriately set.
0
 
shinymoonAuthor Commented:
thanks for your reply :)
The server administrator removed all shared memory segments that are not being used. So, the problem is solved. Thanks.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now