FW: [erlang-questions] Mnesia could not write core file: system_limit

Valentin Micic v@REDACTED
Thu Dec 10 14:31:16 CET 2009



-----Original Message-----
From: Valentin Micic [mailto:v@REDACTED] 
Sent: 10 December 2009 03:06 PM
To: 'Evans, Matthew'
Subject: RE: [erlang-questions] Mnesia could not write core file:
system_limit

Process leaks? Never heard of it ;-)

There is a very simple way to establish how many file descriptors are used.
Assuming that FD = port(), one should be able to establish this by simply
calling:

length( erlang:ports() ).

Not that all ports are created equal, but this figure would roughly
correspond to a number of file descriptors (e.g. open files and sockets) in
use. You may increase a number of file descriptors available to a particular
OS user, hence elrang run-time (VM); however, you would still be required to
ensure that Erlang emulator has access to them by setting ERL_MAX_PORTS
environment variable to appropriate value.

V/

-----Original Message-----
From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On
Behalf Of Evans, Matthew
Sent: 10 December 2009 01:10 AM
To: Bernard Duggan; Slobodan Miskovic
Cc: Erlang-Questions Questions
Subject: RE: [erlang-questions] Mnesia could not write core file:
system_limit

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


________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org



More information about the erlang-questions mailing list