Rémi Bernon : ntdll: Move subheap decommit hysteresis to free_used_block.

Alexandre Julliard julliard at winehq.org
Tue May 24 15:54:59 CDT 2022


Module: wine
Branch: master
Commit: 2c46ee18904b6fef0110d61dabf95046e9e88f2f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2c46ee18904b6fef0110d61dabf95046e9e88f2f

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Tue May 24 08:54:04 2022 +0200

ntdll: Move subheap decommit hysteresis to free_used_block.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>

---

 dlls/ntdll/heap.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
index 1093fde41ca..8e578d19d05 100644
--- a/dlls/ntdll/heap.c
+++ b/dlls/ntdll/heap.c
@@ -649,8 +649,7 @@ static inline BOOL HEAP_Decommit( SUBHEAP *subheap, void *ptr )
     SIZE_T decommit_size;
     SIZE_T size = (char *)ptr - (char *)subheap->base;
 
-    /* round to next block and add one full block */
-    size = ((size + COMMIT_MASK) & ~COMMIT_MASK) + COMMIT_MASK + 1;
+    size = ((size + COMMIT_MASK) & ~COMMIT_MASK);
     size = max( size, subheap->min_commit );
     if (size >= subheap->commitSize) return TRUE;
     decommit_size = subheap->commitSize - size;
@@ -748,7 +747,11 @@ static void free_used_block( SUBHEAP *subheap, struct block *block )
         list_remove( &subheap->entry );
         NtFreeVirtualMemory( NtCurrentProcess(), &addr, &size, MEM_RELEASE );
     }
-    else if (!heap->shared) HEAP_Decommit( subheap, entry + 1 );
+    else if (!heap->shared)
+    {
+        /* keep room for a full commited block as hysteresis */
+        HEAP_Decommit( subheap, (char *)(entry + 1) + (COMMIT_MASK + 1) );
+    }
 }
 
 




More information about the wine-cvs mailing list