summaryrefslogtreecommitdiffstats
path: root/osdep/main-fn-win.c
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-08-25 18:37:34 +0200
committersfan5 <sfan5@live.de>2023-09-01 16:58:56 +0200
commit7f7513132f24344b99645482cd6fd651053d9487 (patch)
tree5351e296ef98ddef7e8cc2a0f4f9bc11ec6349f9 /osdep/main-fn-win.c
parent4f2a12110f029963d50e8ece415ba3668885b692 (diff)
downloadmpv-7f7513132f24344b99645482cd6fd651053d9487.tar.bz2
mpv-7f7513132f24344b99645482cd6fd651053d9487.tar.xz
win32: allow heap cache optimization and memory decommit
Diffstat (limited to 'osdep/main-fn-win.c')
-rw-r--r--osdep/main-fn-win.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/osdep/main-fn-win.c b/osdep/main-fn-win.c
index b0fa62f09e..16ea80bc7f 100644
--- a/osdep/main-fn-win.c
+++ b/osdep/main-fn-win.c
@@ -9,6 +9,18 @@
#include "osdep/terminal.h"
#include "osdep/main-fn.h"
+#ifndef HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION
+
+#define HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION 1
+enum { HeapOptimizeResources = 3 };
+
+struct HEAP_OPTIMIZE_RESOURCES_INFORMATION {
+ DWORD Version;
+ DWORD Flags;
+};
+
+#endif
+
static bool is_valid_handle(HANDLE h)
{
return h != INVALID_HANDLE_VALUE && h != NULL &&
@@ -30,6 +42,13 @@ static void microsoft_nonsense(void)
// Enable heap corruption detection
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
+ // Allow heap cache optimization and memory decommit
+ struct HEAP_OPTIMIZE_RESOURCES_INFORMATION heap_info = {
+ .Version = HEAP_OPTIMIZE_RESOURCES_CURRENT_VERSION
+ };
+ HeapSetInformation(NULL, HeapOptimizeResources, &heap_info,
+ sizeof(heap_info));
+
// Always use safe search paths for DLLs and other files, ie. never use the
// current directory
SetDllDirectoryW(L"");