tags:

views:

53

answers:

2

Is it (theoretically) possible that the process that's been spawn_monitor()'ed exits (with the normal exit or on error) without sending 'DOWN' message to the parent process ? I have a very strange process leakage, it seems like some of the processes do not send 'DOWN' message. I am using Erlang package that comes with Ubuntu 9.10. Maybe it is a known bug ?

A: 

Maybe you demonitored the process at some point?

Reading from the doc for erlang:demonitor/1:

Once erlang:demonitor(MonitorRef) has returned it is guaranteed that no {'DOWN', MonitorRef, _, _, _} message due to the monitor will be placed in the callers message queue in the future. A {'DOWN', MonitorRef, _, _, _} message might have been placed in the callers message queue prior to the call, though. Therefore, in most cases, it is advisable to remove such a 'DOWN' message from the message queue after monitoring has been stopped. erlang:demonitor(MonitorRef, [flush]) can be used instead of erlang:demonitor(MonitorRef) if this cleanup is wanted.

Roberto Aloi
I don't understand why do I need to demonitor() process when it already died ?
Konstantin
I'm not suggesting you to demonitor it. I'm just wondering if you used that function. Sorry about the confusion...
Roberto Aloi
I've just replaced "did" with "maybe" :)
Roberto Aloi
@roberto, No, I did not use this function(). Most certainly it is a bug somewhere in the logic of my program, but I just want to be sure there are no known issues of that sort in Erlang itself.
Konstantin
+1  A: 

You'll need to show some code. Monitoring is pretty core to the way erlang works.

It's hard to tell what your actual problem is since you're not describing what you're seeing, so I'll have to guess.

You're either not trying to receive the down message or the process isn't exiting.

If you have processes leaking, it sounds like they're not actually exiting.

You very well may be trying to build your own supervisor module. I'd strongly suggest using OTP's supervisor if you want sane process tree shutdown and/or restart.

Dustin
I agree with Dustin. It sounds like your processes aren't exiting at all (specially when you say you have a process leak).
Mazen Harake