From: Jim I. <ji...@ap...> - 2000-08-31 01:05:59
|
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... So again, you are limited by the size of the address space, which means that on a 32 bit machine, you won't have problems until you have already allocated 1 Gig, and are going to write a little more beyond that. I think you will be having lots of other problems on most machines long before you get to this point... I don't see paying any performance cost to allow filling a 1 Gig string, and again, if you really need to do this, get a 64 bit machine... With the caveat that WinNT or Win95 may do this in some more brain-dead fashion, and we may need to accommodate them... As a test, try this little program: int main (int argc, char **argv) { int bigsize = 0x5fffffff; char * 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; } I ran it, and it runs fine, then I run top, and get a virtual size of 1.5 Gig (I have 128 Meg of RAM, MacOS X doesn't use a swap partition, but rather uses space in /var/vm, so you have up to the size of the partition var is mounted on, but this is ~800Meg for me...). As you would imagine, the resident size is 504 K... I got NULL back when I ask for ~1.8Gig, so the estimate I gave in the last note is a little high, but still not worth worrying about. Jim -- Jim Ingham ji...@ap... Developer Tools - gdb Apple Computer -- The TclCore mailing list is sponsored by Ajuba Solutions To unsubscribe: email tcl...@aj... with the word UNSUBSCRIBE as the subject. |