stack space in gcd operations
peter at cordes.ca
Tue Aug 18 03:34:01 CEST 2009
On Sun, Aug 16, 2009 at 03:36:20PM -0400, David Harvey wrote:
> I am having a problem with a threaded application using mpz_invert and
> running out of stack space on OS X. The default stack size for new
> threads on OSX is apparently only 512 KB, compared with 8 MB for linux
> (at least on the systems I tried).
Does anyone know why stack space is unpopular? In C, I sometimes use
C99 variable-length arrays on the stack for working space instead of
malloc/free. In C++, I'd use something with a destructor to free any
memory I allocated, but C doesn't have destructors. It doesn't have
exceptions either, but it's ugly using goto out_free instead of
return false on errors.
Hmm, I guess if you touch a lot of stack memory, it's never really
free()d back to the OS, so the OS has to actually page it to disk if
there is memory pressure.
#define X(x,y) x##y
Peter Cordes ; e-mail: X(peter at cor , des.ca)
"The gods confound the man who first found out how to distinguish the hours!
Confound him, too, who in this place set up a sundial, to cut and hack
my day so wretchedly into small pieces!" -- Plautus, 200 BC
More information about the gmp-devel