Alexandre Julliard : ntdll: Go back to growing the heap in smaller increments once we start running out of address space .
Module: wine Branch: master Commit: 5f2300644179869556439dcf4d988285d01cfd20 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5f2300644179869556439dcf4d... Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jun 30 14:07:18 2009 +0200 ntdll: Go back to growing the heap in smaller increments once we start running out of address space. --- dlls/ntdll/heap.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 06490ba..23c0ca2 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -927,11 +927,18 @@ static ARENA_FREE *HEAP_FindFreeBlock( HEAP *heap, SIZE_T size, total_size = size + ROUND_SIZE(sizeof(SUBHEAP)) + sizeof(ARENA_INUSE) + sizeof(ARENA_FREE); if (total_size < size) return NULL; /* overflow */ - if (!(subheap = HEAP_CreateSubHeap( heap, NULL, heap->flags, total_size, - max( heap->grow_size, total_size ) ))) - return NULL; - - if (heap->grow_size < 128 * 1024 * 1024) heap->grow_size *= 2; + if ((subheap = HEAP_CreateSubHeap( heap, NULL, heap->flags, total_size, + max( heap->grow_size, total_size ) ))) + { + if (heap->grow_size < 128 * 1024 * 1024) heap->grow_size *= 2; + } + else while (!subheap) /* shrink the grow size again if we are running out of space */ + { + if (heap->grow_size <= total_size || heap->grow_size <= 4 * 1024 * 1024) return NULL; + heap->grow_size /= 2; + subheap = HEAP_CreateSubHeap( heap, NULL, heap->flags, total_size, + max( heap->grow_size, total_size ) ); + } TRACE("created new sub-heap %p of %08lx bytes for heap %p\n", subheap, subheap->size, heap );
participants (1)
-
Alexandre Julliard