init_cheap and _csbrk

Conrad Scott
Tue Aug 6 15:33:00 GMT 2002

"Christopher Faylor" <> wrote:
> On Tue, Aug 06, 2002 at 07:08:21PM +0100, Conrad Scott wrote:
> I've checked in a modified version of this.  I actually wanted
> allocate some slop for the cygheap but the pagetrunc made sure
> I actually didn't do that.  So, I've changed things so that an
> couple of pages are allocated.  It would be nice to find out
what the
> minimal amount of memory used during a small program would be
> just allocate that at the start to minimize calls to

I wasn't thinking of efficiency while I was looking at this.  I
was actually trying to understand an apparent memory leak on fork.
(I found that BTW: it's the "well-known" one in the per_thread
mechanism.  So I've stopped worrying about it.)

But: the slop will never get used AFAICT (so it's not really
slop).  That is, this padding just pushes the cygheap_max pointer
further up; all subsequent calls to _csbrk will allocate past that
point, and so the slop will remain unused.  So if you want the
slop to be allocated in future, you'll need to drag cygheap_max
back down to (char *) (cygheap + 1) + sbs --- ooh! that looks
familiar --- after the recursive call.  Unless I'm missing the
obvious of course.

> Also my aesthetic sense differs from yours so I didn't apply
that part.

That's the beauty of aesthetics :-)


// Conrad

More information about the Cygwin-patches mailing list