summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2013-08-31 10:21:48 +0000
committerCorinna Vinschen <corinna@vinschen.de>2013-08-31 10:21:48 +0000
commitbffd6fb0e24a3621c9ce3c1ad1583dfc17a5b81c (patch)
tree62e25ecba0ce9b5c31f83828f822732948d5f5e8
parent348f503460715e5f970f27f6b33d892a22e2d86a (diff)
downloadcygnal-bffd6fb0e24a3621c9ce3c1ad1583dfc17a5b81c.tar.gz
cygnal-bffd6fb0e24a3621c9ce3c1ad1583dfc17a5b81c.tar.bz2
cygnal-bffd6fb0e24a3621c9ce3c1ad1583dfc17a5b81c.zip
* heap.cc (RAISEHEAP_SIZE): New definition.
(user_heap_info::sbrk): Make failed commit an error condition again. Only reserve RAISEHEAP_SIZE sized chunk for further heap reservations by default.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/heap.cc18
2 files changed, 19 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index cee6e8da7..f8d238bdc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2013-08-31 Corinna Vinschen <corinna@vinschen.de>
+
+ * heap.cc (RAISEHEAP_SIZE): New definition.
+ (user_heap_info::sbrk): Make failed commit an error condition again.
+ Only reserve RAISEHEAP_SIZE sized chunk for further heap reservations
+ by default.
+
2013-08-30 Christopher Faylor <me.cygwin2013@cgf.cx>
* cygheap.h (user_heap_info::sbrk): Declare new function.
diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc
index 276b77367..d08e8bf17 100644
--- a/winsup/cygwin/heap.cc
+++ b/winsup/cygwin/heap.cc
@@ -24,7 +24,10 @@ details. */
static ptrdiff_t page_const;
+/* Minimum size of the base heap. */
#define MINHEAP_SIZE (4 * 1024 * 1024)
+/* Chunksize of subsequent heap reservations. */
+#define RAISEHEAP_SIZE (1 * 1024 * 1024)
static uintptr_t
eval_start_address ()
@@ -277,20 +280,23 @@ user_heap_info::sbrk (ptrdiff_t n)
we have used up previously reserved memory. Or, we're just plumb out
of memory. Only attempt to commit memory that we know we've previously
reserved. */
- if (newtop <= max && VirtualAlloc (top, commitbytes, MEM_COMMIT,
- PAGE_READWRITE))
- goto good;
+ if (newtop <= max)
+ {
+ if (VirtualAlloc (top, commitbytes, MEM_COMMIT, PAGE_READWRITE))
+ goto good;
+ goto err;
+ }
/* The remainder of the existing heap is too small to fulfill the memory
request. We have to extend the heap, so we reserve some more memory
and then commit the remainder of the old heap, if any, and the rest of
the required space from the extended heap. */
- /* Reserve either the maximum of the standard heap chunk size
- or the requested amount. Then attempt to actually allocate it. */
+ /* For subsequent chunks following the base heap, reserve either 1 Megs
+ per chunk, or the requested amount if it's bigger than 1 Megs. */
reservebytes = commitbytes - ((char *) max - (char *) top);
commitbytes -= reservebytes;
- if ((newbrksize = chunk) < reservebytes)
+ if ((newbrksize = RAISEHEAP_SIZE) < reservebytes)
newbrksize = reservebytes;
if (VirtualAlloc (max, newbrksize, MEM_RESERVE, PAGE_NOACCESS)