TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: STEVE WESTCOT
from: JERRY COFFIN
date: 1997-06-03 09:27:00
subject: Array size too big.

On (01 Jun 97) Steve Westcot wrote to Jerry Coffin...
 JC> Alternatively, you might want to allocate `local_map' dynamically
 JC> so it won't take up nearly your entire stack.
 SW> Dynamically allocate a variable?  I am not sure I understand what that
 SW> means...I use all of the local_map at once...I could load the entire
 SW> map dynamically and then for the local area it would only use what is
 SW> needed.  But that might not be what you mean...I would love some more
 SW> information on it.  I seem to be learning new stuff about C++ daily.
Nope - all I meant was using new or malloc to allocate the space instead
of simply declaring it as a local variable.  We'd be looking at
something like:
struct whatever {
// contents
};
main() {
    whatever *x = new whatever[92 * 21];
// ...
}
This doesn't actually reduce the amount of memory you're using, but it
DOES change the place that it gets allocated, at least on most DOS
compilers.  Under DOS, you're limited to the stack occupying 64K, which
leave roughly 580K of other memory you can use for other purposes.  When
you use malloc or new to allocate space, it comes out of the rest of the
memory, leaving your 64K stack alone.  (Obviously your program occupies
some of that space, but using new/malloc you might still be allocating
out of a pool of 500K instead of a pool of 64K.
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.