Bug 194040 - Miscalculation of free memory with large memory config
Summary: Miscalculation of free memory with large memory config
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: vim
Version: 4.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Karsten Hopp
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-06-05 10:01 UTC by Bastien Nocera
Modified: 2008-01-10 13:36 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-07-10 10:56:57 UTC
Target Upstream Version:
Embargoed:


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

Description Bastien Nocera 2006-06-05 10:01:51 UTC
vim-enhanced-6.3.046-0.40E.7

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 10:01:52 UTC
Created attachment 130486 [details]
vim63-memory-units.patch


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