delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/28/11:18:42

Date: Sun, 28 Jun 1998 18:17:08 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: temujin AT sentex DOT net
cc: djgpp AT delorie DOT com
Subject: Re: Malloc problem.
In-Reply-To: <359474BF.2A46@sentex.net>
Message-ID: <Pine.SUN.3.91.980628180914.11290B-100000@is>
MIME-Version: 1.0

On Sat, 27 Jun 1998 temujin AT sentex DOT net wrote:

> Well as it turns out it was my recursive function that was causing the
> problem.  When it handles more then 7500 calls to itself it seems to go
> off the deep end.

If that recursive function uses more than 35 bytes worth of local 
variables, then calling it recursively 7500 times overflows the 
256KB-large stack that DJGPP programs get by default.  And then your 
program will indeed depart into the never-never land.

You can enlarge the size of your stack by any of the methods described in 
sections 15.9 and 6.4.

> Lesson I learned was that Recursion just isn't worth it.

IMHO, a more appropriate lesson would be that recursion should be only 
used when necessary, and then you need to consider the stack size 
available to the program.  (DJGPP is not the only environment where the 
stack has a fixed size which cannot be enlarged at run time).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019