does malloc cause swapping out?

Kevin Buettner plug-devel@lists.PLUG.phoenix.az.us
Fri Apr 12 17:46:07 2002


On Apr 12,  4:09pm, Kevin Buettner wrote:

> > I would like to know if malloc can cause pages to be swapped out.
> 
> Not directly.  I.e, if you look at the malloc() implementation in
> glibc, you won't find any code responsible for swapping pages out.
> Swapping pages is the kernel's responsibility.

Actually, after reading David Mandala's reply and performing a few
experiments, it appears that merely calling malloc() won't even
cause swapping to occur indirectly.  Of course, if the pages allocated
by malloc are accessed in some way (either read from or written to),
this will cause the kernel to really allocate them and this could
cause paging.

Kevin