From f7c2f1f59ef95d4c4976c56c1bbf718f8036ca87 Mon Sep 17 00:00:00 2001 From: Adam Kocoloski Date: Sat, 7 Mar 2009 18:48:47 +0000 Subject: rewrite replicator using OTP behaviours - only one instance of given source->target runs at a time - supervisor restarts replications that terminate abnormally - pull repl. streams attachments directly to disk - improved memory utilization - temporarily rollback parallel async doc GETs during pull rep. - replication updates show up in Futon Status window git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@751305 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_util.erl | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/couchdb/couch_util.erl') diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index d0f0c0b6..21d6eb4c 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -184,19 +184,18 @@ should_flush() -> should_flush(?FLUSH_MAX_MEM). should_flush(MemThreshHold) -> - case process_info(self(), memory) of - {memory, Mem} when Mem > 2*MemThreshHold -> + {memory, ProcMem} = process_info(self(), memory), + BinMem = lists:foldl(fun({_Id, Size, _NRefs}, Acc) -> Size+Acc end, + 0, element(2,process_info(self(), binary))), + if ProcMem+BinMem > 2*MemThreshHold -> garbage_collect(), - case process_info(self(), memory) of - {memory, Mem} when Mem > MemThreshHold -> + {memory, ProcMem2} = process_info(self(), memory), + BinMem2 = lists:foldl(fun({_Id, Size, _NRefs}, Acc) -> Size+Acc end, + 0, element(2,process_info(self(), binary))), + if ProcMem2+BinMem2 > MemThreshHold -> true; - _ -> - false - end; - _ -> - false - end. - + true -> false end; + true -> false end. %%% Purpose : Base 64 encoding and decoding. -- cgit v1.2.3