mirror of
https://github.com/btdig/dhtcrawler2.git
synced 2025-01-31 02:21:37 +00:00
fix sphinx_build memory leak bug, caused by mongo_cursor
This commit is contained in:
parent
46c99cabd8
commit
e1c905b0a7
@ -100,7 +100,16 @@ try_load_next(_, _) ->
|
||||
do_load_torrents(Skip, Size) ->
|
||||
Conn = mongo_pool:get(?POOLNAME),
|
||||
mongo:do(safe, master, Conn, ?DBNAME, fun() ->
|
||||
% 1: cost lots of memory even close the cursor
|
||||
%Cursor = mongo:find(?COLLNAME, {}, {}, Skip, Size),
|
||||
%Ret = mongo_cursor:rest(Cursor), but close the cursor will reduce the memory
|
||||
% 2: cost lots of memory more than solution 1
|
||||
%Cursor = mongo:find(?COLLNAME, {}, {}, Skip),
|
||||
%mongo_cursor:take(Cursor, Size),
|
||||
% 3:
|
||||
Cursor = mongo:find(?COLLNAME, {}, {}, Skip),
|
||||
mongo_cursor:take(Cursor, Size)
|
||||
Ret = mongo_cursor:take(Cursor, Size),
|
||||
mongo_cursor:close(Cursor),
|
||||
Ret
|
||||
end).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user