Messages in this thread | ![/](/images/icornerl.gif) | | Date | Wed, 11 Dec 1996 20:30:30 -0400 (AST) | From | William Burrow <> | Subject | Re: memory crash |
| |
On Wed, 11 Dec 1996, Alan Cox wrote:
> > this. When a process is allocated memory, the initial memory comes from > > a pool of shared zero-filled pages. These pages don't actually get > > owned by a specific process until a process actually writes to one. > > So does linux
Hmm, so it seems. I just touched up that guy's little test program and sure enough, reading from an unallocated page does not allocate a page (I thought it did; wrong).
I would think a quick check of algorithms to be sure they did not actually assign zeroes to arrays, and all should be fine?
I also got a curious result with the test program. I could malloc up to 6 megs of memory, but at 8 meg, malloc failed. Is malloc() using the stack (which is the only thing limited to 8 meg)?
Result: > ./memory total used free shared buffers cached Mem: 14916 11776 3140 2656 3584 6328 -/+ buffers: 1864 13052 Swap: 0 0 0 malloc(8388608) failed
Here is the slightly modified program: #include <stdio.h> #include <stdlib.h>
int main(void) { char *buff; char y; long i; long max = 1024*1024*8 /* 64 */; system("free");
buff = malloc(max); if( NULL == buff) {printf("malloc(%ld) failed\n", max); return 1;}
for(i=0; i<max; i+=4096) { y=buff[i]; printf(" %2x ", y); } printf("\n");
system("free");
free( buff ); return 0; }
-- William Burrow -- Fredericton Area Network, New Brunswick, Canada Copyright 1996 William Burrow Canada's federal regulator says it may regulate content on the Internet to provide for more Canadian content. (Ottawa Citizen 15 Nov 96 D15)
| ![\](/images/icornerr.gif) |