Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi committed Oct 17, 2024
2 parents 9087c4a + a6020c6 commit ff62545
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/os_mon/c_src/memsup.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,10 @@ get_extended_mem_apple(memory_ext *me) {
}

me->free = vm_stat.free_count * mach_page_size;
me->available = (vm_stat.inactive_count + vm_stat.free_count) * mach_page_size;
me->total = total_memory_size;
me->pagesize = 1;
me->flag = F_MEM_TOTAL | F_MEM_FREE;
me->flag = F_MEM_TOTAL | F_MEM_FREE | F_MEM_AVAIL;
}
#endif

Expand Down Expand Up @@ -508,7 +509,11 @@ get_basic_mem(unsigned long *tot, unsigned long *used, unsigned long *pagesize){
}
*tot = me.total;
*pagesize = me.pagesize;
*used = me.total - me.free;
if (me.flag & F_MEM_AVAIL) {
*used = me.total - me.available;
} else {
*used = me.total - me.free;
}
#elif defined(BSD4_4)
struct vmtotal vt;
long pgsz;
Expand All @@ -535,9 +540,9 @@ get_basic_mem(unsigned long *tot, unsigned long *used, unsigned long *pagesize){
#elif defined(__APPLE__)
{
memory_ext me;
me.free = 0;
me.available = 0;
get_extended_mem_apple(&me);
*used = me.total - me.free;
*used = me.total - me.available;
*tot = total_memory_size;
*pagesize = 1;
}
Expand Down
4 changes: 3 additions & 1 deletion lib/os_mon/src/memsup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ Periodically performs a memory check:
- If more than a certain amount of available system memory is allocated, as
reported by the underlying operating system, the alarm
`{system_memory_high_watermark, []}` is set.
`{system_memory_high_watermark, []}` is set. How the amount of available
memory is determined depends on the underlying OS and may change as better
values become available.
- If any Erlang process `Pid` in the system has allocated more than a certain
amount of total system memory, the alarm
`{process_memory_high_watermark, Pid}` is set.
Expand Down
3 changes: 3 additions & 0 deletions lib/os_mon/test/memsup_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@ improved_system_memory_data(Config) when is_list(Config) ->
_ ->
{comment, "No available_memory present in result"}
end;
{unix,darwin} ->
true = AvailableMemoryPresent,
{comment, "available_memory present in result"};
_ ->
ok
end.
Expand Down

0 comments on commit ff62545

Please sign in to comment.