[erlang-questions] Memory usage with gen_tcp

Bob Ippolito <>
Thu Sep 18 18:38:19 CEST 2008


You might want to try specifying the min_heap_size to some smaller
number when spawning the processes, I don't recall the OTP
machinations to do that off the top of my head though. Check spawn_opt
for docs on how to tweak that in core erlang
http://www.erlang.org/doc/man/erlang.html

On Thu, Sep 18, 2008 at 8:19 AM, Paul Oliver <> wrote:
> Hi all,
>
> I have a simple echo server built on top of mochiweb_socket_server
> (http://mochiweb.googlecode.com/svn/trunk/src/mochiweb_socket_server.erl):
>
> -define(DEFAULTS, [{ip, "127.0.0.1"}, {loop, {?MODULE, loop}}, {name,
> ?MODULE}, {port, 8888}, {max, 100000}]).
>
> start() ->
>    start(?DEFAULTS).
>
> start(Options) ->
>    mochiweb_socket_server:start(Options).
>
> loop(Socket) ->
>    case gen_tcp:recv(Socket, 0) of
>        {ok, Data} ->
>            gen_tcp:send(Socket, Data),
>            loop(Socket);
>        {error, closed} ->
>            ok
>    end.
>
> I'm load testing and have found that the memory used in the echo
> server per connected client is approximately 40K.  I've tried setting
> sndbuf and recbuf to 1024 respectively (hardcoded in
> mochiweb_socket_server), but this doesn't seem to make a difference.
> Does anybody know where I should be looking to reduce this figure?
>
> Thanks,
> Paul.
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list