Browse Source

prevent large pages alloc on switch

Nicolas Cannasse 1 year ago
parent
commit
bbae569cc9
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/allocator.c

+ 6 - 0
src/allocator.c

@@ -129,6 +129,7 @@ static gc_pheader *gc_allocator_new_page( int pid, int block, int size, int kind
 	// increase size based on previously allocated pages
 	if( block < 256 ) {
 		int num_pages = 0;
+		int count = 1;
 		gc_pheader *ph = gc_pages[pid];
 		while( ph ) {
 			num_pages++;
@@ -136,7 +137,12 @@ static gc_pheader *gc_allocator_new_page( int pid, int block, int size, int kind
 		}
 		while( num_pages > 8 && (size<<1) / block <= GC_PAGE_SIZE ) {
 			size <<= 1;
+			count <<= 1;
 			num_pages /= 3;
+#			ifdef HL_NX
+			// do not allocate too much large pages with low memory
+			if( count == 4 ) break;
+#			endif
 		}
 	}