LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2010, 06:45 AM   #1
parrotfortytwo
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Rep: Reputation: 0
Free shared memory of dead process


Hello, I have the problem that a process crashes, but does not free up its shared memory after itself. Thus, next time I want to start it, it crashes again this time due for the lack of shared memory (I know it from the error message).
Is there a way to find out which memory the crashed process was occupying, and to somehow free it manually? Otherwise I always have to reboot the machine if I want to start the process again.
 
Old 11-01-2010, 06:53 AM   #2
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Maybe you can look in system monitor and find running process, it's under Applications >> System Tools >> System Monitor under processes tab. Dmesg also tells alot. Linux newbie here too.
 
Old 11-01-2010, 07:11 AM   #3
parrotfortytwo
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
I had already done something similar to looking into system monitor*, but the process was not there (since it had crashed). To be sure, I tried now to look into the system monitor as well, but it was not there either.
Now I also tried dmesg, as you suggested, but I do not know what I should look for :S It really tells a lot of things, but they seem to me more hardware related...



* more exactly, I did:
Code:
ps aux | grep <process>
 
Old 11-01-2010, 11:04 AM   #4
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

shared memory can be viewed with
Code:
ipcs
. You can delete shared memory segments with
Code:
ipcrm
.
 
Old 11-01-2010, 02:18 PM   #5
parrotfortytwo
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks, mesiol; these were the commands I was looking for -- next time the process crashes I will try them out.
In Google, I kept finding man pages of C functions for managing shared memory...
 
Old 11-01-2010, 05:42 PM   #6
mesiol
Member
 
Registered: Nov 2008
Location: Lower Saxony, Germany
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731

Rep: Reputation: 137Reputation: 137
Hi,

if this is your solution, so please mark the thread as solved.
 
Old 11-02-2010, 05:11 AM   #7
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 136Reputation: 136
Quote:
Originally Posted by parrotfortytwo View Post
Hello, I have the problem that a process crashes, but does not free up its shared memory after itself. Thus, next time I want to start it, it crashes again this time due for the lack of shared memory (I know it from the error message).
Is there a way to find out which memory the crashed process was occupying, and to somehow free it manually? Otherwise I always have to reboot the machine if I want to start the process again.
You may change executable to deal with shared memory segment already exist
(Correct thing IMO) This will make it more robust.
 
Old 11-02-2010, 01:34 PM   #8
parrotfortytwo
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
mesiol: did that now
Valery Reznic: could you please give me the name of the command (or a pointer to the documentation) on how to do that?
 
Old 11-03-2010, 02:56 AM   #9
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 136Reputation: 136
Quote:
Originally Posted by parrotfortytwo View Post
mesiol: did that now
Valery Reznic: could you please give me the name of the command (or a pointer to the documentation) on how to do that?
See 'man shmget'

I guess that your shared memory created with code like following:
Code:
shmget(key, size, IPC_CREAT | IPC_EXCL);
IPC_CREAT | IPC_EXCL force shmget return error if shared memory already exist.

If you remove IPC_EXCL flag it will work when shared memory already exist and when it not.

Last edited by Valery Reznic; 11-03-2010 at 02:59 AM.
 
  


Reply


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
shared memory between user process and kernel roydcruz Linux - Kernel 9 01-22-2010 04:23 AM
Creating more than one shared memory by a process anoopmenons Linux - Embedded & Single-board computer 1 11-15-2009 12:11 PM
Creating more than one shared memory by a process anoopmenons Linux - Software 1 11-15-2009 10:15 AM
Difference between resident memory,shared memory and virtual memory in system monitor mathimca05 Linux - Newbie 1 11-11-2007 04:05 AM
Accessing shared memory opened in a windows process in a connected linux pc gonzalesmico Programming 3 06-07-2007 02:31 PM


All times are GMT -5. The time now is 12:37 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration