Patch 7.4.1033
Problem:    Memory use on MS-Windows is very conservative.
Solution:   Use the global memory status to estimate amount of memory.
            (Mike Williams)
Files:      src/os_win32.c, src/os_win32.h, src/proto/os_win32.pro


*** ../vim-7.4.1032/src/os_win32.c      2015-11-02 14:45:12.135936003 +0100
--- src/os_win32.c      2016-01-02 21:10:53.507824345 +0100
***************
*** 5858,5863 ****
--- 5858,5923 ----
  #endif
  }
  
+ /* physical RAM to leave for the OS */
+ #define WINNT_RESERVE_BYTES     (256*1024*1024)
+ #define WIN95_RESERVE_BYTES       (8*1024*1024)
+ 
+ /*
+  * How much main memory in KiB that can be used by VIM.
+  */
+ /*ARGSUSED*/
+     long_u
+ mch_total_mem(int special)
+ {
+     PlatformId();
+ #if (defined(_MSC_VER) && (WINVER > 0x0400)) || defined(MEMORYSTATUSEX)
+     if (g_PlatformId == VER_PLATFORM_WIN32_NT)
+     {
+       MEMORYSTATUSEX  ms;
+ 
+       /* Need to use GlobalMemoryStatusEx() when there is more memory than
+        * what fits in 32 bits. But it's not always available. */
+       ms.dwLength = sizeof(MEMORYSTATUSEX);
+       GlobalMemoryStatusEx(&ms);
+       if (ms.ullAvailVirtual < ms.ullTotalPhys)
+       {
+           /* Process address space fits in physical RAM, use all of it. */
+           return (long_u)(ms.ullAvailVirtual / 1024);
+       }
+       if (ms.ullTotalPhys <= WINNT_RESERVE_BYTES)
+       {
+           /* Catch old NT box or perverse hardware setup. */
+           return (long_u)((ms.ullTotalPhys / 2) / 1024);
+       }
+       /* Use physical RAM less reserve for OS + data. */
+       return (long_u)((ms.ullTotalPhys - WINNT_RESERVE_BYTES) / 1024);
+     }
+     else
+ #endif
+     {
+       /* Pre-XP or 95 OS handling. */
+       MEMORYSTATUS    ms;
+       long_u          os_reserve_bytes;
+ 
+       ms.dwLength = sizeof(MEMORYSTATUS);
+       GlobalMemoryStatus(&ms);
+       if (ms.dwAvailVirtual < ms.dwTotalPhys)
+       {
+           /* Process address space fits in physical RAM, use all of it. */
+           return (long_u)(ms.dwAvailVirtual / 1024);
+       }
+       os_reserve_bytes = (g_PlatformId == VER_PLATFORM_WIN32_NT)
+           ? WINNT_RESERVE_BYTES
+           : WIN95_RESERVE_BYTES;
+       if (ms.dwTotalPhys <= os_reserve_bytes)
+       {
+           /* Catch old boxes or perverse hardware setup. */
+           return (long_u)((ms.dwTotalPhys / 2) / 1024);
+       }
+       /* Use physical RAM less reserve for OS + data. */
+       return (long_u)((ms.dwTotalPhys - os_reserve_bytes) / 1024);
+     }
+ }
  
  #ifdef FEAT_MBYTE
  /*
*** ../vim-7.4.1032/src/os_win32.h      2014-03-23 15:12:29.943264337 +0100
--- src/os_win32.h      2016-01-02 21:02:57.441032810 +0100
***************
*** 78,83 ****
--- 78,85 ----
  # define BREAKCHECK_SKIP    1 /* call mch_breakcheck() each time, it's fast */
  #endif
  
+ #define HAVE_TOTAL_MEM
+ 
  #define HAVE_PUTENV           /* at least Bcc 5.2 and MSC have it */
  
  #ifdef FEAT_GUI_W32
*** ../vim-7.4.1032/src/proto/os_win32.pro      2015-11-10 20:52:00.937285809 
+0100
--- src/proto/os_win32.pro      2016-01-02 21:02:57.441032810 +0100
***************
*** 43,48 ****
--- 43,49 ----
  void mch_delay __ARGS((long msec, int ignoreinput));
  int mch_remove __ARGS((char_u *name));
  void mch_breakcheck __ARGS((void));
+ long_u mch_total_mem __ARGS((int special));
  int mch_wrename __ARGS((WCHAR *wold, WCHAR *wnew));
  int mch_rename __ARGS((const char *pszOldFile, const char *pszNewFile));
  char *default_shell __ARGS((void));
*** ../vim-7.4.1032/src/version.c       2016-01-02 20:59:05.607566224 +0100
--- src/version.c       2016-01-02 21:04:29.424026124 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     1033,
  /**/

-- 
TIM:   That is not an ordinary rabbit ... 'tis the most foul cruel and
       bad-tempered thing you ever set eyes on.
ROBIN: You tit.  I soiled my armour I was so scared!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui