aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2016-12-15 09:47:02 +0100
committerHans Bolinder <[email protected]>2017-01-11 09:34:58 +0100
commit657760e18087b0cdbaecc5e96e46f6f66bc9497a (patch)
tree419f420dc736e4d8862ec1af40ee8c5ab9474116
parent3c6dbbeb252247ef97cad93921deb4c6e313f11b (diff)
downloadotp-657760e18087b0cdbaecc5e96e46f6f66bc9497a.tar.gz
otp-657760e18087b0cdbaecc5e96e46f6f66bc9497a.tar.bz2
otp-657760e18087b0cdbaecc5e96e46f6f66bc9497a.zip
compiler: Do not spawn process when dialyzing
Memory consumption is reduced during the compilation phase by keeping the Core parse tree shared. In particular the file annotation takes a lot of memory when not shared.
-rw-r--r--lib/compiler/src/compile.erl30
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 434360d294..e37ca31704 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -173,17 +173,25 @@ env_default_opts() ->
do_compile(Input, Opts0) ->
Opts = expand_opts(Opts0),
- {Pid,Ref} =
- spawn_monitor(fun() ->
- exit(try
- internal(Input, Opts)
- catch
- error:Reason ->
- {error,Reason}
- end)
- end),
- receive
- {'DOWN',Ref,process,Pid,Rep} -> Rep
+ IntFun = fun() -> try
+ internal(Input, Opts)
+ catch
+ error:Reason ->
+ {error,Reason}
+ end
+ end,
+ %% Dialyzer has already spawned workers.
+ case lists:member(dialyzer, Opts) of
+ true ->
+ IntFun();
+ false ->
+ {Pid,Ref} =
+ spawn_monitor(fun() ->
+ exit(IntFun())
+ end),
+ receive
+ {'DOWN',Ref,process,Pid,Rep} -> Rep
+ end
end.
expand_opts(Opts0) ->