mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-01-15 01:29:11 +08:00
possible fix for memory instability on Win7 (#230)
This commit is contained in:
parent
77acf5a868
commit
093db6af24
5
src/os.c
5
src/os.c
@ -212,9 +212,11 @@ static void* mi_win_virtual_allocx(void* addr, size_t size, size_t try_alignment
|
|||||||
void* p = VirtualAlloc(hint, size, flags, PAGE_READWRITE);
|
void* p = VirtualAlloc(hint, size, flags, PAGE_READWRITE);
|
||||||
if (p != NULL) return p;
|
if (p != NULL) return p;
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
if (err != ERROR_INVALID_ADDRESS) { // if linked with multiple instances, we may have tried to allocate at an already allocated area
|
if (err != ERROR_INVALID_ADDRESS && // If linked with multiple instances, we may have tried to allocate at an already allocated area (#210)
|
||||||
|
err != ERROR_INVALID_PARAMETER) { // Windows7 instability (#230)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
// fall through
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(MEM_EXTENDED_PARAMETER_TYPE_BITS)
|
#if defined(MEM_EXTENDED_PARAMETER_TYPE_BITS)
|
||||||
@ -228,6 +230,7 @@ static void* mi_win_virtual_allocx(void* addr, size_t size, size_t try_alignment
|
|||||||
return (*pVirtualAlloc2)(GetCurrentProcess(), addr, size, flags, PAGE_READWRITE, ¶m, 1);
|
return (*pVirtualAlloc2)(GetCurrentProcess(), addr, size, flags, PAGE_READWRITE, ¶m, 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// last resort
|
||||||
return VirtualAlloc(addr, size, flags, PAGE_READWRITE);
|
return VirtualAlloc(addr, size, flags, PAGE_READWRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user