Red Hat Bugzilla – Bug 194040
Miscalculation of free memory with large memory config
Last modified: 2008-01-10 08:36:47 EST
In os_unix.c, mch_total_mem() doesn't use the mem_unit member of the sysinfo
struct to calculate the amount of memory available.
# if defined(HAVE_SYS_SYSINFO_H) && defined(HAVE_SYSINFO)
if (mem == 0)
struct sysinfo sinfo;
/* Linux way of getting amount of RAM available */
if (sysinfo(&sinfo) == 0)
mem = sinfo.totalram;
fprintf (stderr, "HAVE_SYSINFO mem = %ld\n", mem);
So with large amounts of memory (such as a very large swap), vim would
miscalculate the free memory as .mem_unit would be != 1.
Here's an example patch for RH/Fedora. This is probably not suitable to push
upstream as it increases memory usage on 32-bit machines (64-bit integer instead
of 32 for a lot of variables), and wouldn't work on 2.2 kernels where .mem_info
isn't available (whether upstream care about those...).
Created attachment 130486 [details]