Permalink
Browse files

Trigger a GC when OS process is returned

  • Loading branch information...
1 parent b9f0271 commit e9440aef1c6cc708b3bd531876658485cb60ec86 @kocolosk kocolosk committed with Robert Newson Dec 3, 2011
Showing with 4 additions and 0 deletions.
  1. +3 −0 apps/couch/src/couch_os_process.erl
  2. +1 −0 apps/couch/src/couch_proc_manager.erl
@@ -168,6 +168,9 @@ handle_cast({send, Data}, #os_proc{writer=Writer, idle=Idle}=OsProc) ->
end;
handle_cast(stop, OsProc) ->
{stop, normal, OsProc};
+handle_cast(garbage_collect, #os_proc{idle=Idle} = OsProc) ->
+ erlang:garbage_collect(),
+ {noreply, OsProc, Idle};
handle_cast(Msg, #os_proc{idle=Idle}=OsProc) ->
?LOG_DEBUG("OS Proc: Unknown cast: ~p", [Msg]),
{noreply, OsProc, Idle}.
@@ -67,6 +67,7 @@ handle_call({ret_proc, #proc{client=Ref, pid=Pid} = Proc}, _From, State) ->
% #proc{} from our own table, so the alternative is to do a lookup in the
% table before the insert. Don't know which approach is cheaper.
case is_process_alive(Pid) of true ->
+ gen_server:cast(Pid, garbage_collect),
ets:insert(State#state.tab, Proc);
false -> ok end,
{reply, true, State};

0 comments on commit e9440ae

Please sign in to comment.