George Reilly wrote:
> 2008/8/23 Jelle Geerts <[EMAIL PROTECTED]>: > > Hello, > > > > When allocating memory, lalloc() is called, which uses mch_avail_mem(). But > > mch_avail_mem() sometimes fails. It returns the available physical memory + > > available page file memory, which can sometimes wrap around 32-bits. > > > > Also, mch_avail_mem() uses GlobalMemoryStatus() which isn't working > > properly on > > computers with more than 4 GiB of memory installed. There is an extension > > available on NT platforms 0x0500, called GlobalMemoryStatusEx(). As opposed > > to > > GlobalMemoryStatus(), the extension works reliably with systems that have > > more > > than 4 GiB of memory installed. > > > > Please see the attachment for the diff file for my patch. If the comments I > > have added are too wordy or someone does not like them, just remove them ;) > > > > Thanks, > > Jelle Geerts > > It looks to me like your patch will fail if ms.dwAvailPhys is more > than 4GiB, due to underflow of (0xffffff00 - ms.dwAvailPhys). This is > a DWORDLONG, which is always an unsigned 64-bit int. > > Also, shouldn't that be msex.ullAvailPhys, not ms.dwAvailPhys in the > (_WIN32_WINNT >= 0x0500) && !defined(_WIN64) case? > > Better, I think, to return (long_u) min(0xFFFFFF00, msex.ullAvailPhys > + msex.ullAvailPageFile). Or for Bram to widen this signature to a > 64-bit int for all platforms. Linux and Mac boxes with >4GiB are going > to be common soon. I don't think that Vim needs to know if you have more than 4 Gbyte available. Just make sure mch_avail_mem() doesn't wrap around and returns a number close to 4 Gbyte when there is more. Unfortunately, 64-bit support isn't very well standardized. And there are systems that don't support it at all. -- A radioactive cat has eighteen half-lives. /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
