www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/30/03:01:34

Xref: news2.mv.net comp.os.msdos.djgpp:6558
From: Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Flat Memory Questions
Date: Mon, 29 Jul 1996 22:44:22 CDT
Organization: Rice University, Houston, Texas
Lines: 26
Message-ID: <31fd8516.sandmann@clio.rice.edu>
References: <720 DOT 9607281807 AT ws-ai5 DOT dur DOT ac DOT uk>
Reply-To: sandmann AT clio DOT rice DOT edu
NNTP-Posting-Host: clio.rice.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> 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.

"Using large amounts of stack" isn't bad practice in general - just on systems
that aren't properly implemented :-)  (Hey, I'm allowed to bash what I wrote!)

This is just a big wart on the DPMI 0.9 stuff - DJGPP V1.x under non-DPMI
didn't have it, VMS doesn't have it, unix doesn't have it, etc.

> Array is now static: ie a 1Mb array is made inside your executable, working but
> leading to a bloated >1Mb executable!

The bloat should only happen with C++, and can be avoided with a command line
switch.

> Third choice: malloc: dynamic, no disadvantages.

Big disadvantages: memory leaks, reentrancy of malloc, freeing memory on
exception unwinding (you usually can't, more leaks), bad malloc packages, etc.

For anyone out there who wants dynamic stack expansion, there is a potentially
slow way to do it by starting the stack at 0xffffffff and expanding down in
the same memory block, using a unixy sbrk type algorithm.  Morten and I 
talked about it a while, but we got busy and didn't write it...  Sigh.

- Raw text -


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