diff options
author | Anders Svensson <[email protected]> | 2016-09-07 23:05:47 +0200 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2016-09-11 14:45:01 +0200 |
commit | 392a0a77a9c4fc4c9bdca1c2e6599ce34f07c93b (patch) | |
tree | d97260c1fb2db9632674e4e43b44307babc679f7 /lib/diameter/src | |
parent | 3b7a6ffddc819bf305353a593904cea9e932e7dc (diff) | |
download | otp-392a0a77a9c4fc4c9bdca1c2e6599ce34f07c93b.tar.gz otp-392a0a77a9c4fc4c9bdca1c2e6599ce34f07c93b.tar.bz2 otp-392a0a77a9c4fc4c9bdca1c2e6599ce34f07c93b.zip |
Let unfortunate min_heap_size setting be disabled
The setting in all diameter server processes has existed since the
beginning of time. Whether it's actually useful is questionable, but it
does lead to increased memory usage, especially if there are many peer
connections whose processes wouldn't otherwise be large. Let the setting
be disabled with -diameter min_heap_size false. (Or any value that isn't
a non-negative integer.)
The diameter application itself only calls
diameter_lib:spawn_opts(server, []), but let other arguments remain for
backwards compatibility, since diameter_lib:spawn_opts/2 has been abused
from outside of diameter.
Diffstat (limited to 'lib/diameter/src')
-rw-r--r-- | lib/diameter/src/base/diameter_lib.erl | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/diameter/src/base/diameter_lib.erl b/lib/diameter/src/base/diameter_lib.erl index b835e87967..3928769b5e 100644 --- a/lib/diameter/src/base/diameter_lib.erl +++ b/lib/diameter/src/base/diameter_lib.erl @@ -299,8 +299,28 @@ spawn_opts(server, Opts) -> spawn_opts(worker, Opts) -> opts(5000, Opts). -opts(HeapSize, Opts) -> - [{min_heap_size, HeapSize} | lists:keydelete(min_heap_size, 1, Opts)]. +%% These setting are historical rather than useful. In particular, the +%% server setting can bloat many processes unnecessarily. Let them be +%% disabled with -diameter min_heap_size false. + +opts(Def, Opts) -> + Key = min_heap_size, + case getenv(Key, Def) of + N when is_integer(N), 0 =< N -> + [{Key, N} | lists:keydelete(Key, 1, Opts)]; + _ -> + Opts + end. + +%% getenv/1 + +getenv(Key, Def) -> + case application:get_env(Key) of + {ok, T} -> + T; + undefined -> + Def + end. %% --------------------------------------------------------------------------- %% # wait/1 |