diff options
author | Adam Kocoloski <adam@cloudant.com> | 2011-12-03 16:34:05 -0500 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2012-11-14 17:27:06 +0000 |
commit | e9440aef1c6cc708b3bd531876658485cb60ec86 (patch) | |
tree | 7986bf98a9ae80b76e77229726f1fda8c8c90dac /apps/couch | |
parent | b9f0271cf63efed0af5c3c4aec5a31c928da1079 (diff) |
Trigger a GC when OS process is returned
Diffstat (limited to 'apps/couch')
-rw-r--r-- | apps/couch/src/couch_os_process.erl | 3 | ||||
-rw-r--r-- | apps/couch/src/couch_proc_manager.erl | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/apps/couch/src/couch_os_process.erl b/apps/couch/src/couch_os_process.erl index 0c6f284f..fb4bd5a9 100644 --- a/apps/couch/src/couch_os_process.erl +++ b/apps/couch/src/couch_os_process.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}. diff --git a/apps/couch/src/couch_proc_manager.erl b/apps/couch/src/couch_proc_manager.erl index 568608bc..d09893eb 100644 --- a/apps/couch/src/couch_proc_manager.erl +++ b/apps/couch/src/couch_proc_manager.erl @@ -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}; |