From: Jeffrey H. <jef...@aj...> - 2000-08-31 01:20:58
|
> From: Jim Ingham [mailto:ji...@ap...] ... > On Wednesday, August 30, 2000, at 04:49 PM, Jeffrey Hobbs wrote: > > > Yes and no. Sure, the memory is just reserved, but the mem allocator > > will still bomb if you ask for more space than it could promise. The > > point of the mem efficiency part is that we don't get too greedy about > > needing so much more space than we need. That way we can push the > > boundaries of how much mem we will actually be able to use without > > the mem allocator crapping out because we're overly greedy. > > > > Yes, but the point of the last note was that what "more" is is pretty > huge. For instance, I think in general the allocator doesn't check > whether a given allocation fits in the available swap space but > rather fills it as you actually write out pages to swap. This is the > right thing to do, since that way you can for instance allocate a > large matrix, and if you only fill it sparsely, you aren't limited by > the size of the matrix, only by the pages you use. MacOS X, does it > this way, at least. I imagine other Unixes work in much the same way... It's always a bummer about those theories, because Unix really does limit you to known available mem space (note that 1610612735 == 0x5fffffff): nerja [~/tmp/mem] 183 % gcc -o testmem mem.c nerja [~/tmp/mem] 184 % testmem 1610612735 Oops, could not allocate 1610612735 bytes nerja [~/tmp/mem] 185 % testmem 810612735 Oops, could not allocate 810612735 bytes nerja [~/tmp/mem] 186 % testmem 410612735 Oops, could not allocate 410612735 bytes nerja [~/tmp/mem] 187 % testmem 210612735 I allocated 210612735d bytes ^C nerja [~/tmp/mem] 188 % cat mem.c int main (int argc, char **argv) { int bigsize = 0x5fffffff; char * foo; if (argc == 2) { bigsize = atoi(argv[1]); } foo = (char *) malloc(bigsize); if (!foo) { printf("Oops, could not allocate %d bytes\n", bigsize); return 1; } else { printf("I allocated %ud bytes\n", bigsize); } foo[500] = 'c'; foo[0xffffff] = 'd'; while (1) ; return 0; } With the last, you get 480K resident on a 200+MB size program from top. This is a Solaris/x86 machine. You could jack up your swap space quite a bit, but that'll get you into trouble for other reasons if someone actually got around to using it. Jeffrey Hobbs Tcl Ambassador ho...@Aj... Ajuba Solutions (nee Scriptics) -- The TclCore mailing list is sponsored by Ajuba Solutions To unsubscribe: email tcl...@aj... with the word UNSUBSCRIBE as the subject. |