Alex Rivera | Logout

Are some allocators lazy?

Asked 2009-05-14T16:38:46.580
16

I wrote a C program in Linux that mallocs memory, ran it in a loop, and TOP didn't show any memory consumption.

then I've done something with that memory, and TOP did show memory consumption.

When I malloc, do I really "get memory", or is there a "lazy" memory management, that only gives me the memory if/when I use it?

(There is also an option that TOP only know about memory consumption when I use it, so I'm not sure about this..)

Thanks

Edit
Report

1 Answer

2

The feature is called overcommit - kernel "promises" you memory by increasing the data segment size, but does not allocate physical memory to it. When you touch an address in that new space the process page-faults into the kernel, which then tries to map physical pages to it.

answered 2009-05-14T21:23:16.990

Your Answer