mod_mam_mnesia: Force garbage collection

The VM fails to collect the garbage generated during MAM lookups
automatically, so mod_mam_mnesia's memory usage easily goes up to
several gigabytes if we don't force garbage collection.
This commit is contained in:
Holger Weiss 2016-06-29 22:32:59 +02:00
parent 10d4c16a97
commit 8be1d49961
1 changed files with 9 additions and 6 deletions

View File

@ -138,12 +138,15 @@ select(_LServer, JidRequestor,
SortedMsgs = lists:keysort(#archive_msg.timestamp, Msgs),
{FilteredMsgs, IsComplete} = filter_by_rsm(SortedMsgs, RSM),
Count = length(Msgs),
{lists:map(
fun(Msg) ->
{Msg#archive_msg.id,
jlib:binary_to_integer(Msg#archive_msg.id),
mod_mam:msg_to_el(Msg, MsgType, JidRequestor, JidArchive)}
end, FilteredMsgs), IsComplete, Count}.
Result = {lists:map(
fun(Msg) ->
{Msg#archive_msg.id,
jlib:binary_to_integer(Msg#archive_msg.id),
mod_mam:msg_to_el(Msg, MsgType, JidRequestor,
JidArchive)}
end, FilteredMsgs), IsComplete, Count},
erlang:garbage_collect(),
Result.
%%%===================================================================
%%% Internal functions