Skip to content

Commit

Permalink
prevent large pages alloc on switch
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Oct 23, 2023
1 parent b02120b commit bbae569
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,20 @@ 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++;
ph = ph->next_page;
}
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
}
}

Expand Down

0 comments on commit bbae569

Please sign in to comment.