[erlang-questions] EUnit error test: limit number of processes at runtime

22 views
Skip to first unread message

Christian Kruse

unread,
Apr 28, 2012, 1:06:26 PM4/28/12
to erlang-q...@erlang.org
Hi,

for an Erlang project I'm working on (Open Source,
<https://github.com/ckruse/irckerl> in case someone is curious) I'm
trying to test a possible error with spawning a process, e.g. maximum
number of processes reached. Since I don't want to spawn > 32k
processes for each test run, I'd like to limit the number of possible
processes for this test only.

Is this possible? Or is there another solution I can use to test such
an error case?

Greetings,
CK

Kostis Sagonas

unread,
Apr 28, 2012, 1:11:05 PM4/28/12
to erlang-q...@erlang.org
Have you considered using the +P option of erl?

Kostis
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Christian Kruse

unread,
Apr 28, 2012, 1:19:03 PM4/28/12
to erlang-q...@erlang.org
Hi,

On 28/04/12 19:11, Kostis Sagonas wrote:
> >for an Erlang project I'm working on (Open Source,
> ><https://github.com/ckruse/irckerl> in case someone is curious) I'm
> >trying to test a possible error with spawning a process, e.g. maximum
> >number of processes reached. Since I don't want to spawn> 32k
> >processes for each test run, I'd like to limit the number of possible
> >processes for this test only.
> >
> >Is this possible? Or is there another solution I can use to test such
> >an error case?
>
> Have you considered using the +P option of erl?

Yes, but since I want to reduce this limit only for one specific test
it is not really a good solution. I would have to set the limit to a
specific number of processes for all tests and exceed that limit in
the error test. Of course it can be much lower than 32k processes for
the test run, but it would be much nicer to limit it only for this one
test.

Greetings,
CK

Geoff Cant

unread,
Apr 28, 2012, 3:24:12 PM4/28/12
to c...@wwwtech.de, erlang-q...@erlang.org
From memory there's no way to limit the number of processes allowed aside from the size of the process table. The size of the process table is set at startup and can't be changed, so I guess the answer to your question is No - you have to spawn enough processes to run out. spawn(fun () -> erlang:hibernate(erlang, exit, [normal]) end, []) might help with the memory footprint a bit.

Cheers,
-Geoff
> _______________________________________________
> erlang-questions mailing list
> erlang-q...@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions

--
Geoff Cant

Lukas Larsson

unread,
May 1, 2012, 5:56:15 AM5/1/12
to c...@wwwtech.de, erlang-q...@erlang.org
Hi,

You could also spawn a slave[1] node in the test with your desired
parameters to test this behaviour. That is how it is done in the
Erlang/OTP test suites.

Lukas

[1] : http://erlang.org/doc/man/slave.html
Reply all
Reply to author
Forward
0 new messages