Here worked example. https://gist.github.com/AZatvornitskiy/4732830(simple_couch_db_doc_behavior.erl)
On Thu, Feb 7, 2013 at 6:58 PM, Алекс Zatvornitskiy < [email protected]> wrote: > +1 ) I don't think that `gdb` will give me answers. I've not had enough > knowledge about `couch_db`, `couch_doc` modules. > > > On Thu, Feb 7, 2013 at 6:42 PM, Paul Davis <[email protected]>wrote: > >> I'm confused by what's generating the inactive memory messages. Some >> sort of Erlang tracing? >> >> On Thu, Feb 7, 2013 at 10:36 AM, Алекс Zatvornitskiy >> <[email protected]> wrote: >> > 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!) >> > >
