diff options
author | Hans Bolinder <[email protected]> | 2016-12-19 10:02:12 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-01-11 09:34:59 +0100 |
commit | 7f3b77274958b62523e83ab2b37ad29ec9a6cf3c (patch) | |
tree | 47276a031c0210ae2f533b47962962042ec854d7 /lib/dialyzer/src/dialyzer_contracts.erl | |
parent | 2bcf8a6159e3b370739b835b52b95ff73c54776f (diff) | |
download | otp-7f3b77274958b62523e83ab2b37ad29ec9a6cf3c.tar.gz otp-7f3b77274958b62523e83ab2b37ad29ec9a6cf3c.tar.bz2 otp-7f3b77274958b62523e83ab2b37ad29ec9a6cf3c.zip |
dialyzer: Reduce memory consumption during 'remote' phase
The cache used for speeding up the translation from forms to types is
no longer global, but reset per module. The peak memory consumption
is reduced, and the added time seems to be small.
Diffstat (limited to 'lib/dialyzer/src/dialyzer_contracts.erl')
-rw-r--r-- | lib/dialyzer/src/dialyzer_contracts.erl | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index 331786466f..82275d5df7 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -165,17 +165,15 @@ process_contract_remote_types(CodeServer) -> {{MFA, {File, Contract, Xtra}}, C2} end, ModuleFun = - fun({ModuleName, ContractDict}, C3) -> - {NewContractList, C4} = - lists:mapfoldl(ContractFun, C3, dict:to_list(ContractDict)), - {{ModuleName, dict:from_list(NewContractList)}, C4} + fun({ModuleName, ContractDict}) -> + Cache = erl_types:cache__new(), + {NewContractList, _NewCache} = + lists:mapfoldl(ContractFun, Cache, dict:to_list(ContractDict)), + {ModuleName, dict:from_list(NewContractList)} end, erlang:garbage_collect(), - Cache = erl_types:cache__new(), - {NewContractList, C5} = - lists:mapfoldl(ModuleFun, Cache, dict:to_list(TmpContractDict)), - {NewCallbackList, _C6} = - lists:mapfoldl(ModuleFun, C5, dict:to_list(TmpCallbackDict)), + NewContractList = lists:map(ModuleFun, dict:to_list(TmpContractDict)), + NewCallbackList = lists:map(ModuleFun, dict:to_list(TmpCallbackDict)), NewContractDict = dict:from_list(NewContractList), NewCallbackDict = dict:from_list(NewCallbackList), %% Make sure the (huge) cache is garbage collected: |