aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/src/dialyzer_cl.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2017-01-20 15:28:33 +0100
committerHans Bolinder <[email protected]>2017-02-03 08:58:01 +0100
commit416711a87dcc937d78990ada5da0b8df98a8e1ee (patch)
tree6269f2ab53d0295f5bea2a82c29c936690154435 /lib/dialyzer/src/dialyzer_cl.erl
parent7e0a7a58eb3557bd0d5d372a3793119a5e9ffe61 (diff)
downloadotp-416711a87dcc937d78990ada5da0b8df98a8e1ee.tar.gz
otp-416711a87dcc937d78990ada5da0b8df98a8e1ee.tar.bz2
otp-416711a87dcc937d78990ada5da0b8df98a8e1ee.zip
dialyzer: Write PLT in subprocess
At common case, which will otherwise leave a big heap.
Diffstat (limited to 'lib/dialyzer/src/dialyzer_cl.erl')
-rw-r--r--lib/dialyzer/src/dialyzer_cl.erl22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/dialyzer/src/dialyzer_cl.erl b/lib/dialyzer/src/dialyzer_cl.erl
index 93200f53d2..8500c59ebe 100644
--- a/lib/dialyzer/src/dialyzer_cl.erl
+++ b/lib/dialyzer/src/dialyzer_cl.erl
@@ -710,8 +710,16 @@ return_value(State = #cl_state{code_server = CodeServer,
true ->
dialyzer_plt:delete(MiniPlt);
false ->
- Plt = dialyzer_plt:restore_full_plt(MiniPlt),
- dialyzer_plt:to_file(OutputPlt, Plt, ModDeps, PltInfo)
+ Fun = to_file_fun(OutputPlt, MiniPlt, ModDeps, PltInfo),
+ {Pid, Ref} = erlang:spawn_monitor(Fun),
+ dialyzer_plt:give_away(MiniPlt, Pid),
+ Pid ! go,
+ receive {'DOWN', Ref, process, Pid, Result} ->
+ case Result of
+ ok -> ok;
+ Thrown -> throw(Thrown)
+ end
+ end
end,
UnknownWarnings = unknown_warnings(State),
RetValue =
@@ -732,6 +740,16 @@ return_value(State = #cl_state{code_server = CodeServer,
{RetValue, set_warning_id(AllWarnings)}
end.
+-spec to_file_fun(_, _, _, _) -> fun(() -> no_return()).
+
+to_file_fun(Filename, MiniPlt, ModDeps, PltInfo) ->
+ fun() ->
+ receive go -> ok end,
+ Plt = dialyzer_plt:restore_full_plt(MiniPlt),
+ dialyzer_plt:to_file(Filename, Plt, ModDeps, PltInfo),
+ exit(ok)
+ end.
+
unknown_warnings(State = #cl_state{legal_warnings = LegalWarnings}) ->
Unknown = case ordsets:is_element(?WARN_UNKNOWN, LegalWarnings) of
true ->