diff --git a/source/lib/sysdep/win/win.cpp b/source/lib/sysdep/win/win.cpp index 9ed3406acf..f55352bb13 100755 --- a/source/lib/sysdep/win/win.cpp +++ b/source/lib/sysdep/win/win.cpp @@ -355,6 +355,23 @@ static void at_exit(void) // be very careful to avoid non-stateless libc functions! static inline void pre_libc_init() { +#if WINVER >= 0x0501 + // enable low-fragmentation heap + HMODULE hKernel32Dll = LoadLibrary("kernel32.dll"); + if(hKernel32Dll) + { + BOOL (WINAPI* pHeapSetInformation)(HANDLE, HEAP_INFORMATION_CLASS, void*, size_t); + *(void**)&pHeapSetInformation = GetProcAddress(hKernel32Dll, "HeapSetInformation"); + if(pHeapSetInformation) + { + ULONG flags = 2; // enable LFH + HeapSetInformation(GetProcessHeap(), HeapCompatibilityInformation, &flags, sizeof(flags)); + } + + FreeLibrary(hKernel32Dll); + } +#endif // #if WINVER >= 0x0501 + cs_init(); GetSystemDirectory(win_sys_dir, sizeof(win_sys_dir)); diff --git a/source/lib/sysdep/win/win_internal.h b/source/lib/sysdep/win/win_internal.h index 1e73c8e0d7..028c0e0a08 100755 --- a/source/lib/sysdep/win/win_internal.h +++ b/source/lib/sysdep/win/win_internal.h @@ -38,7 +38,7 @@ #undef _WINDOWS_ // set version; needed for EnumDisplayDevices -#define _WIN32_WINNT 0x0500 +#define _WIN32_WINNT 0x0501