[erlang-questions] mnesia memory leak?

Dale Harvey harveyd@REDACTED
Sat May 30 02:06:12 CEST 2009


Sorry last email was a bit wrong, If I run the
mnesia..garb() functions the memory does level
out, however if I do 50,000 reads, then collect, wait
a while, then do more, still no memory is released
(crunched the ouput because it was a tad large)

Cheers
Dale

-module(test).
-compile(export_all).

test_collect() ->
    init(),
    [ run(collect) || _X <- lists:seq(1, 50)],
    ok.

test_nocollect() ->
    init(),
    [ run() || _X <- lists:seq(1, 50)],
    ok.

info() ->
    io:format("ets memory ~p~n", [erlang:memory(ets)]).

run() ->
    info(),
    [ read() || _X <- lists:seq(1, 10000)],
    info().

run(collect) ->
    info(),
    [ read() || _X <- lists:seq(1, 10000)],
    collect(),
    info().

collect() ->
    mnesia_recover:allow_garb(),
    mnesia_recover:start_garb().

read() ->
    mnesia:activity(transaction, fun mnesia:first/1, [test]).

init() ->
    application:stop(mnesia),
    ok = mnesia:delete_schema([node()]),
    ok = mnesia:create_schema([node()]),
    application:start(mnesia),
    mnesia:create_table(test, [{type, bag}, {attributes, [id, field1]}]).

Output:

1> test:nocollect().
ets memory 176940
ets memory 825368
...
ets memory 4700472
ets memory 4698912
...
ets memory 11801864
ets memory 12449608
...
ets memory 26655536
ets memory 26653984
...
ets memory 31820984
ets memory 32468712
ok
2> test:collect().
true
3> test:info().
32468844

2> test:collect().
ets memory 197956
ets memory 845860
...
ets memory 6676980
...
ets memory 6681516
ets memory 6682036
...
ets memory 6687844
ets memory 6687844
ets memory 6688380
...
ets memory 6697404
ets memory 6697932
ok

2009/5/30 Dale Harvey <harveyd@REDACTED>

> Did this patch make it into R13?
>
> I am observing similiar behaviour, I have tried
> adding the allow_garb() start_garb() but still seeing
> ets continously grow without releasing memory,
>
> Checking ets:i() I can see there are various
> mnesia_transient_decision table created that
> grow permanently.
>
> The memory growth seems identical even if I
> run the tests inside a spawned process that
> dies
>
> 1> test:test().
> erlang 176316
> erlang 824852
> ok
> 2> test:run().
> erlang 824852
> erlang 1472756
> ok
> 3> test:run().
> erlang 1472756
> erlang 2120644
> 4> spawn( fun() -> test:run() end).
> erlang 2120644
> <0.30083.0>
> erlang 2768540
>
> -module(test).
> -compile(export_all).
>
> test() ->
>     application:stop(mnesia),
>     ok = mnesia:delete_schema([node()]),
>     ok = mnesia:create_schema([node()]),
>     application:start(mnesia),
>     mnesia:create_table(test, [{type, bag}, {attributes, [id, field1]}]),
>
>     run(),
>
>     ok.
>
> info() ->
>     io:format("ets memory ~p~n", [erlang:memory(ets)]).
>
> run() ->
>     info(),
>     [ read() || _X <- lists:seq(1, 10000)],
>     mnesia_recover:allow_garb(),
>     mnesia_recover:start_garb(),
>     info().
>
> read() ->
>     mnesia:activity(transaction, fun mnesia:first/1, [test]).
>
>
>
> 2008/7/10 andrey-google <buricchio@REDACTED>
>
> That's very good news.
>> Thanks a lot to Mog and Dan.
>>
>> dvader
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
>
>


More information about the erlang-questions mailing list