mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 23:19:31 +03:00
fix issue #210 where multiple static instances of mimalloc in DLL's compete for the same virtual memory area
This commit is contained in:
parent
5bc276c23b
commit
72f758c433
1 changed files with 6 additions and 1 deletions
7
src/os.c
7
src/os.c
|
@ -209,7 +209,12 @@ static void* mi_win_virtual_allocx(void* addr, size_t size, size_t try_alignment
|
||||||
// on 64-bit systems, try to use the virtual address area after 4TiB for 4MiB aligned allocations
|
// on 64-bit systems, try to use the virtual address area after 4TiB for 4MiB aligned allocations
|
||||||
void* hint;
|
void* hint;
|
||||||
if (addr == NULL && (hint = mi_os_get_aligned_hint(try_alignment,size)) != NULL) {
|
if (addr == NULL && (hint = mi_os_get_aligned_hint(try_alignment,size)) != NULL) {
|
||||||
return VirtualAlloc(hint, size, flags, PAGE_READWRITE);
|
void* p = VirtualAlloc(hint, size, flags, PAGE_READWRITE);
|
||||||
|
if (p != NULL) return p;
|
||||||
|
DWORD err = GetLastError();
|
||||||
|
if (err != ERROR_INVALID_ADDRESS) { // if linked with multiple instances, we may have tried to allocate at an already allocated area
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(MEM_EXTENDED_PARAMETER_TYPE_BITS)
|
#if defined(MEM_EXTENDED_PARAMETER_TYPE_BITS)
|
||||||
|
|
Loading…
Add table
Reference in a new issue