LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 01-18-2013, 02:21 PM   #1
wj123
LQ Newbie
 
Registered: Mar 2011
Posts: 7

Rep: Reputation: 0
what happens to undeleted pointer when a process exist?


In our application, we have an process that forks a child process. In the child process, it creates a object using new but does not delete it.

So what happens to the memory when the child process exists? Will the undeleted pointer still take up system memory? The child process is forked by the parnet process over and over. The child process runs for a while and then exists.

Related, the child process create a socket, but does not close it. So what happens to the socket when the process closes? Will it linger around and exhaust the socket pool eventually? Thanks.

(I undertand those are problems and need to be fixed, I just want to know whan happens to existing application.)

WJ
 
Old 01-18-2013, 02:36 PM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
At the time fork() is called the child becomes a copy of the parent. Anything new the child makes ends when the child exits.
 
Old 01-18-2013, 02:49 PM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
When a process exits, any files it left open are closed and all of its memory is released.

There are some other kinds of system resources that a process can "leak" and leave around on exit. I think a GUI process using an X server can leave resource leaks in the X server.

The simple stuff (open files and the process's own memory) are recovered on exit, but other things might not be. I don't have the details on the things that might be leaked, just occasional painful experience.

Quote:
Originally Posted by wj123 View Post
In the child process, it creates a object using new but does not delete it.
That is one of the simple ones, entirely in the process's own memory. Entirely cleaned up on process exit; No problem.

Last edited by johnsfine; 01-18-2013 at 02:51 PM.
 
Old 01-18-2013, 09:06 PM   #4
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by johnsfine View Post
kinds of system resources that a process can "leak" and leave around on exit
shared memory segments
 
Old 01-19-2013, 05:56 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
plus semaphores and alike
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
process checker script finds process that dnt exist andrewcrawford Linux - Newbie 2 05-01-2009 08:10 AM
can a dangling pointer exist in java??? silverlander Programming 18 11-16-2008 10:38 AM
mythbacken process doesn't exist doralsoral Linux - Software 1 12-12-2005 03:52 AM
Are delete files undeleted? thrustan Linux - Security 4 03-09-2005 01:06 PM
How to find out the instruction pointer of a process? shy Programming 3 10-23-2004 04:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:26 AM.

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