[erlang-questions] mnesia memory leak?

Dan Gudmundsson <>
Thu Jul 10 08:47:19 CEST 2008


Hmm the problem in R12 is that it doesn't garbage collect if there is no log to be dumped 
when the node uses disk, i.e. no transactions to disk tables are being done.

Here is the patch that will make it to the next release.

/Dan

Patch:
mnesia_dumper.erl
116,122c116,117
< 	    case mnesia_monitor:use_dir() of
< 		true ->
< 		    dumped;
< 		_ ->
< 		    mnesia_recover:allow_garb(),
< 		    dumped
< 	    end;
---
 > 	    mnesia_recover:allow_garb(),
 > 	    dumped;


mnesia_recover.erl
106,111c106,119
<     Old = val(previous_transient_decisions),
<     Next = create_transient_decision(),
<     {Prev, ReallyOld} = sublist([Curr | Old], 10, []),
<     [?ets_delete_table(Tab) || Tab <- ReallyOld],
<     set(previous_transient_decisions, Prev),
<     set(latest_transient_decision, Next).
---
 >     %% Don't garb small tables, they are created on every
 >     %% dump_log and may be small (empty) for schema transactions
 >     %% which are dumped twice
 >     case ets:info(Curr, size) > 20 of
 > 	true ->
 > 	    Old = val(previous_transient_decisions),
 > 	    Next = create_transient_decision(),
 > 	    {Prev, ReallyOld} = sublist([Curr | Old], 10, []),
 > 	    [?ets_delete_table(Tab) || Tab <- ReallyOld],
 > 	    set(previous_transient_decisions, Prev),
 > 	    set(latest_transient_decision, Next);
 > 	false ->
 > 	    ignore
 >     end.


mog wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> mog wrote:
> | Hi
> | I am working with mnesia in my app and after several hours of running 
> it seems that my memory usage has gone over 1 gig.  At first I thought 
> this was a bug in my code that interfaces with mnesia, but upon looking 
> at my tables they are all reasonably small, however, ets:i() reveals
> | 745             mnesia_transient_decision set   5940587 95901642 
> mnesia_recover
> |
> | upon googling around i found that this seems to be a known issue?   
> What is the proper way to deal with this?  I also found the following 
> http://yanovsky.agenstvo.com/?p=31  <- he appears to have the same issue 
> i do, and provides easy test code to expose the issue.
> |
> | Mog
> sorry to reply to my own message but i thought seeing as how this want 
> documented anywhere i could see and to double check this is an 
> appropriate way to fix my problem.
> 
> mnesia_recovery:allow_garb(),
> mnesia_recovery:start_garb().
> 
> that seems to clean up my memory problem.  I guess I shouldn't have said 
> memory leak exactly, just seems mnesia doesn't want to free memory while 
> under load, and given that my app has constant load that isn't really an 
> option for me.
> 
> Mog
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFIdTnNeq+tARrxhnsRAhm2AJ9jphA1ofOyYSqqcdep3cLUeru/NwCgoZU0
> mx4dCDn1GhWBaprzyit+dPg=
> =KMU3
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



More information about the erlang-questions mailing list