Date: Sun, 28 Jul 1996 20:53:08 -0400 (EDT) From: David M Barrett To: Sengan DOT Short AT durham DOT ac DOT uk cc: djgpp AT delorie DOT com Subject: Re: Flat Memory Questions In-Reply-To: <720.9607281807@ws-ai5.dur.ac.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Wow, I learn something new everyday. I've never really pieced together that connection before. Thanks! Also, why is this being cc'd to djgpp AT delorie DOT com? One more question (because you seem to be quite knowledgeable): do you know where the docs to fsdb can be found? Thanks a lot for all of the help! -David :) ----------------------------------------------------------------------------- David M. Barrett :) | University of Michigan / CAEN Hotline dbarrett AT engin DOT umich DOT edu | http://www-personal.engin.umich.edu/~dbarrett ----------------------------------------------------------------------------- On Sun, 28 Jul 1996 Sengan DOT Short AT durham DOT ac DOT uk wrote: > > > > Wow, thanks a lot. I to malloc a meg and it worked just fine. But, when > > I tried to defind a static array (ie- char Array[1024 * 1024]) I got a > > wierd runtime error > > > > Exiting due to signal SIGSEGV > > Stack fault at ... > > eax=... > > ebp=... > > Call from traceback EIPs: > > 0x000015b9 > > > > (the ...'s should be replaced with a ton of numbers and info). > > > > I tried to allocate the array on the first line of the main function. > > The rest of the program is simply printf statements (except for a line > > that sets one of the array values to 5, but it never gets that far). Is > > there something wrong with allocating a buffer this way? > > void main (void) > { char Array[1024*1024]; ...} > Array is put on the stack. But there is only 256Kb on the stack, so the rest > of your stack is all over your program. Anyway it is bad practice to use large > amounts of stack. You should allocate it dynamically if you want big amounts > of memory. > > char Array[1024*1024]; > void main ( void ) > { ... } > Array is now static: ie a 1Mb array is made inside your executable, working but > leading to a bloated >1Mb executable! > > Third choice: malloc: dynamic, no disadvantages. > > Sengan >