Hi There! First of all, thanks a ton for CouchDB )
I've couple of strange memory issues with R15B03 and couch db internals.
It'd be great to have a clearance for questions.
Let's consider short code snippet:
db_and_doc() ->
{<<"seed_labeled_prod">>, <<"medianet:album:10000053">>}.
write(Body) ->
{DbName, DocId} = db_and_doc(),
{ok, Db} = couch_db:open_int(DbName, []),
couch_db:update_doc(Db, Body, []),
couch_db:close(Db).
read() ->
{DbName, DocId} = db_and_doc(),
{ok, Db} = couch_db:open_int(DbName, []),
{ok, Doc} = couch_db:open_doc(Db, DocId),
{Body} = couch_doc:to_json_obj(Doc, []),
couch_db:close(Db),
Body.
And few cases:
run(Scenario) ->
spawn(fun() -> in_case(Scenario) end).
in_case(single_process) ->
Seq = lists:seq(1, 30000),
Try = fun(_) -> write(read()) end,
lists:foreach(Try, Seq);
in_case(spawned_processes) ->
Seq = lists:seq(1, 5000),
Try = fun(_) ->
spawn(fun() -> write(read()) end)
end,
lists:foreach(Try, Seq);
in_case(spawned_update_processes) ->
Seq = lists:seq(1, 30000),
Try = fun(_) ->
Doc = read(),
spawn(fun() -> write(Doc) end)
end,
lists:foreach(Try, Seq).
My questions are:
1] Why `in_case(single_process)` produces so many `inactive` memory on Mac
OS X in case when `<<"medianet:album:10000053">>` document size is 67.19Kb?;
-- besides, `in_case(spawned_processes)` doesn't;
2] moreover, `in_case(spawned_update_processes)` still continue produce an
`inactive` memory;
I think that Linux env has same behavior.
Thanks for help!)