ref: fc81c094e3234ae8f0fb2e892fee32b1b7e01fd9
parent: 30978c725d744d1fa502cd45e87d7af71564061b
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Feb 7 18:33:34 EST 2014
cwfs: limit memsize() to 1GB until pool can handle huge allocations
--- a/sys/src/cmd/cwfs/malloc.c
+++ b/sys/src/cmd/cwfs/malloc.c
@@ -4,7 +4,7 @@
static ulong
memsize(void)
{- ulong pgsize, userpgs, userused;
+ ulong pgsize, pgmax, userpgs, userused;
char *s, *f[2];
int n, mpcnt;
Biobuf *bp;
@@ -29,6 +29,7 @@
Bterm(bp);
}
if(pgsize && userused < userpgs){+ userpgs -= userused;
if(s = getenv("fsmempercent")){mpcnt = atoi(s);
free(s);
@@ -35,7 +36,11 @@
}
if(mpcnt < 1)
mpcnt = 1;
- return ((userpgs-userused)*mpcnt/100)*pgsize;
+ userpgs = (userpgs*mpcnt)/100;
+ pgmax = (1024*1024*1024)/pgsize; /* 1GB max */
+ if(userpgs > pgmax)
+ userpgs = pgmax;
+ return userpgs*pgsize;
}
return 16*MB;
}
--
⑨