Bug 194040 - Miscalculation of free memory with large memory config
Miscalculation of free memory with large memory config
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: vim (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Karsten Hopp
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2006-06-05 06:01 EDT by Bastien Nocera
Modified: 2008-01-10 08:36 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-07-10 06:56:57 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
vim63-memory-units.patch (743 bytes, patch)
2006-06-05 06:01 EDT, Bastien Nocera
no flags Details | Diff

  None (edit)
Description Bastien Nocera 2006-06-05 06:01:51 EDT

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);
#  endif

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...).
Comment 1 Bastien Nocera 2006-06-05 06:01:52 EDT
Created attachment 130486 [details]

Note You need to log in before you can comment on or make changes to this bug.