memory insanity

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

memory insanity

Steve Langstaff
Just out of interest... does it leak by (sizeof(.beam) x number of file reads) ?

--
Steve L.

On 14 September 2001 09:08, Matthias Lang [SMTP:matthias] wrote:

> Hi,
>
> Using R7B-3, this program bloats at a rate of about 100k per second on
> my intel linux box. It does similar things on my PPC board. I've
> watched it go up to 20Mb (using 'top') before stopping it.
>
> I'd much appreciate it if a few people could confirm this result, a
> result from a commercial solaris version would be interesting too.
>
> Run it in the same directory as the .beam (it reads the .beam file):
>
>   leaky:go().
>
> Matthias
>
> ----------------------------------------------------------------------
> -module(leaky).
> -author('matthias').
>
> -compile(export_all).
> -record(state, {eth_curr, eth_prev}).
>
> go() -> loop(#state{}).
>
> loop(State) ->
>     State1 = update_ethernet(State),
>     erlang:garbage_collect(),
>     loop(State1).
>
> update_ethernet(State) ->
>     Bin = grab_eth(),
>     Prev = State#state.eth_curr,
>     State#state{eth_curr = {now(), Bin}, eth_prev = Prev}.
>
> grab_eth() ->
>     {ok, IF} = file:open("leaky.beam", [raw, binary, read]),
>     {ok, Bin} = file:read(IF, 2000),
>     ok = file:close(IF),
>     Bin.


Reply | Threaded
Open this post in threaded view
|

memory insanity

Matthias Lang-2
Steve Langstaff writes:
 > Just out of interest... does it leak by (sizeof(.beam) x number of file reads) ?

No. Very roughly (just looking at top), my BEAM is 3.5M to start with,
after 100k loops, it's about 5M, so I'd put the leak somewhere in the
vicinity of 15 bytes/loop.

Raimo just posted a patch and noted that the patch fixes a 40 byte
leak in file:close. My measurement isn't inconsistent with that. I
haven't tested the patch yet (my main machine currently doesn't work
and compiling Erlang on my old pentium takes forever).

Matthias