- heapOverflow();
- }
- if (RtsFlags.GcFlags.maxHeapSize != 0) {
- size_reserved_pool = BLOCK_SIZE * RtsFlags.GcFlags.maxHeapSize;
- if (size_reserved_pool < MBLOCK_SIZE) {
- size_reserved_pool = 2*MBLOCK_SIZE;
- }
- }
- base_non_committed = VirtualAlloc ( NULL
- , size_reserved_pool
- , MEM_RESERVE
- , PAGE_READWRITE
- );
- membase = base_non_committed;
- if ( base_non_committed == 0 ) {
- errorBelch("getMBlocks: VirtualAlloc MEM_RESERVE %lu failed with: %ld\n", size_reserved_pool, GetLastError());
- ret=(void*)-1;
- } else {
- end_non_committed = (char*)base_non_committed + (unsigned long)size_reserved_pool;
- /* The returned pointer is not aligned on a mega-block boundary. Make it. */
- base_mblocks = (char*)((unsigned long)base_non_committed & (unsigned long)~MBLOCK_MASK) + MBLOCK_SIZE;
-# if 0
- debugBelch("getMBlocks: Dropping %d bytes off of 256M chunk\n",
- (unsigned)base_mblocks - (unsigned)base_non_committed);
-# endif
-
- if ( ((char*)base_mblocks + size) > end_non_committed ) {
- debugBelch("getMBlocks: oops, committed too small a region to start with.");
- ret=(void*)-1;
- } else {
- next_request = base_mblocks;
- }