File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ define PROJECT_ENV
16
16
{ssl_options, []},
17
17
{vm_memory_high_watermark, 0.4},
18
18
{vm_memory_high_watermark_paging_ratio, 0.5},
19
- {vm_memory_use_process_rss, true },
19
+ {vm_memory_calculation_strategy, rss },
20
20
{memory_monitor_interval, 2500},
21
21
{disk_free_limit, 50000000}, %% 50MB
22
22
{msg_store_index_module, rabbit_msg_store_ets_index},
Original file line number Diff line number Diff line change @@ -495,15 +495,32 @@ read_proc_file(IoDevice, Acc) ->
495
495
eof -> Acc
496
496
end .
497
497
498
+ -spec get_memory_calculation_strategy () -> rss | erlang .
499
+ get_memory_calculation_strategy () ->
500
+ case application :get_env (rabbit , vm_memory_calculation_strategy , rss ) of
501
+ erlang ->
502
+ erlang ;
503
+ rss ->
504
+ rss ;
505
+ UnsupportedValue ->
506
+ rabbit_log :warning (
507
+ " Unsupported value '~p ' for vm_memory_calculation_strategy. "
508
+ " Supported values: (rss|erlang). "
509
+ " Defaulting to 'rss'" ,
510
+ [UnsupportedValue ]
511
+ ),
512
+ rss
513
+ end .
514
+
498
515
499
516
% % Memory reported by erlang:memory(total) is not supposed to
500
517
% % be equal to the total size of all pages mapped to the emulator,
501
518
% % according to http://erlang.org/doc/man/erlang.html#memory-0
502
519
% % erlang:memory(total) under-reports memory usage by around 20%
503
520
-spec get_used_memory () -> Bytes :: integer ().
504
521
get_used_memory () ->
505
- case application : get_env ( rabbit , vm_memory_use_process_rss , false ) of
506
- true ->
522
+ case get_memory_calculation_strategy ( ) of
523
+ rss ->
507
524
case get_system_process_resident_memory () of
508
525
{ok , MemInBytes } ->
509
526
MemInBytes ;
@@ -513,7 +530,7 @@ get_used_memory() ->
513
530
[Reason ]),
514
531
erlang :memory (total )
515
532
end ;
516
- false ->
533
+ erlang ->
517
534
erlang :memory (total )
518
535
end .
519
536
You can’t perform that action at this time.
0 commit comments