Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 1 commit
  • 2 files changed
  • 0 comments
  • 1 contributor
Sep 03, 2013
Simon Cornish Fix inconsistency in free_memory value on Linux platforms
The documentation for memsup:get_system_memory_data() states the
free_memory element contains the "amount of free memory available to
the Erlang emulator for allocation". However later a note states that
this is not true for Linux.

This patch corrects the inconsistency by adding the memory allocated by
kernel buffers and caches back to the kernel "free" value. It also
modifies the note to the effect that these value are included in
free_memory.

With this patch, a user application that monitors and/or reports free
memory can rely on the meaning of free_memory to be consistent across
deployed platforms.
802dd2d
4  lib/os_mon/c_src/memsup.c
@@ -442,7 +442,9 @@ get_basic_mem(unsigned long *tot, unsigned long *used, unsigned long *pagesize){
442 442
     }
443 443
     *tot      = me.total;
444 444
     *pagesize = me.pagesize;
445  
-    *used     = me.total - me.free;
  445
+    *used     = me.total - me.free
  446
+      + (me.flag & F_MEM_BUFFERS ? me.buffered : 0)
  447
+      + (me.flag & F_MEM_CACHED  ? me.cached   : 0);
446 448
 #elif defined(BSD4_4)
447 449
     struct vmtotal vt;
448 450
     long pgsz;
4  lib/os_mon/doc/src/memsup.xml
@@ -209,8 +209,8 @@
209 209
         <p>Returns the empty list [] if <c>memsup</c> is not available,
210 210
           or if the memory check times out.</p>
211 211
 	<note><p>
212  
-	On linux the memory available to the emulator is <c>cached_memory</c> and <c>buffered_memory</c> in addition to 
213  
-	<c>free_memory</c>.</p>
  212
+	  On linux the memory available to the emulator in <c>free_memory</c>
  213
+	  includes <c>cached_memory</c> and <c>buffered_memory</c>.</p>
214 214
 	</note>
215 215
       </desc>
216 216
     </func>

No commit comments for this range

Something went wrong with that request. Please try again.