[erlang-questions] Mnesia could not write core file: system_limit
Evans, Matthew
mevans@REDACTED
Thu Dec 10 00:09:43 CET 2009
To handle process leaks (especially if you are using a gen_server / gen_fsm behaviour) I normally return a timeout from my handle_call, handle_info, handle_cast etc. functions.
I have the time the process started and the time of the last event in my State record, and then have logic in the handle_info(timeout,State) function to cause the process to "self destruct" if it thinks it's been around too long.
There is a small performance overhead of starting a timer in your process, but it does trap these sort of problems.
Regards
Matt
________________________________________
From: erlang-questions@REDACTED [erlang-questions@REDACTED] On Behalf Of Bernard Duggan [bernie@REDACTED]
Sent: Wednesday, December 09, 2009 6:00 PM
To: Slobodan Miskovic
Cc: Erlang-Questions Questions
Subject: Re: [erlang-questions] Mnesia could not write core file: system_limit
Slobodan Miskovic wrote:
> Heh, thinking outside of the (VM) box - guess there is no query-able
> interface in Erlang for this? Linux is then indeed simple enough:
> {ok, FDList} = file:list_dir("/proc/self/fd"),
> length(FDList)
>
Huh - never noticed the 'self' symlink - that's really handy :)
As far as I know there's no specific interface in Erlang for this - I'd
expect it to either be in maybe os: or erlang:, but I can't see anything
there.
> What about other platforms, ie. Windows?
>
Sorry, I can't help you there.
> Would lsof (or similar mechanism) be preferable as I would get a list of
> open sockets and network connections which as I understand all
> contribute to the max open ports limit. Would I get all those in
> the /proc/.../fd list as well?
>
/proc/self/fd should include all file descriptors that contribute to the
process's limit - pipes, sockets, files etc. It's what we use for
monitoring exactly this issue on some of our C++ code.
> Hm, I have embedded Yaws running, and occasionally processes terminate
> when invalid requests comes in. I would have thought those would have
> been really dead. I'll have to keep an eye on the running system to see
> if number of processes is rising.
>
Proces leaks are the memory leaks of Erlang - they're relatively easy to
accidentally code if you're not careful.
If you're running a long-running server app I'd suggest looking at
providing an SNMP monitoring system to keep an eye on this kind of thing
- Erlang's built-in SNMP stuff is a pain in the backside to initially
set up, but once you've got it going it's trivial to add a lot of really
informative information.
Cheers,
B
________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org
More information about the erlang-questions
mailing list