Memory allocation: do not use mmap for memory allocation on 64 bit.
On Windows we can only do mmap memory allocation up to 4 GB, which causes a crash when doing very large renders on 64 bit systems with a lot of memory. As far as I can tell the reason to use mmap is to get around address space limitation on some 32 bit operating systems, and I can't see a reason to use it on 64 bit. For the original explanation see here: http://orange.blender.org/blog/stupid-memory-problems Fixes T37841.
This commit is contained in:
@@ -541,6 +541,12 @@ void *MEM_guarded_mapallocN(size_t len, const char *str)
|
||||
{
|
||||
MemHead *memh;
|
||||
|
||||
/* on 64 bit, simply use calloc instead, as mmap does not support
|
||||
* allocating > 4 GB on Windows. the only reason mapalloc exists
|
||||
* is to get around address space limitations in 32 bit OSes. */
|
||||
if(sizeof(void*) >= 8)
|
||||
return MEM_lockfree_callocN(len, str);
|
||||
|
||||
len = SIZET_ALIGN_4(len);
|
||||
|
||||
#if defined(WIN32)
|
||||
|
@@ -265,6 +265,12 @@ void *MEM_lockfree_mapallocN(size_t len, const char *str)
|
||||
{
|
||||
MemHead *memh;
|
||||
|
||||
/* on 64 bit, simply use calloc instead, as mmap does not support
|
||||
* allocating > 4 GB on Windows. the only reason mapalloc exists
|
||||
* is to get around address space limitations in 32 bit OSes. */
|
||||
if(sizeof(void*) >= 8)
|
||||
return MEM_lockfree_callocN(len, str);
|
||||
|
||||
len = SIZET_ALIGN_4(len);
|
||||
|
||||
#if defined(WIN32)
|
||||
|
@@ -129,6 +129,7 @@ void *mmap(void *UNUSED(start), size_t len, int prot, int flags, int fd, off_t o
|
||||
}
|
||||
}
|
||||
|
||||
/* note len is passed to a 32 bit DWORD, so can't be > 4 GB */
|
||||
maphandle = CreateFileMapping(fhandle, NULL, prot_flags, 0, len, NULL);
|
||||
if (maphandle == 0) {
|
||||
errno = EBADF;
|
||||
|
Reference in New Issue
Block a user