delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/28/17:09:57

Date: Thu, 28 Oct 1999 19:14:57 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Nicolas Blais <nicblais AT hotmail DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Stack space
In-Reply-To: <7v71od$vas$1@nnrp1.deja.com>
Message-ID: <Pine.SUN.3.91.991028191437.9453G-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 27 Oct 1999, Nicolas Blais wrote:

> All of my DJGPP progs use the default stack space of 512K.  So,
> obviously my programs crashes when it uses more then 512K.  I know I can
> change this value with stub but I don't really want to.  What I want to
> do is to create a variable with new like such:
> double x = new double;
> 
> And make him use a part of memory that's already in use by another
> program, like windows for example.  Let's say that I have that address
> and I want to store a new variable there, how could I do it?

You are mixing several types of ``memory'' used by the DJGPP programs
in particular and by other programs running on Windows, in general.

First, besides the stack, your program also uses the ``heap'', a
portion of memory that is allocated by calls to malloc and new.  The
stack is only used by variables that are local to functions, like in
the following example:

    int foo (void)
    {
      int i, j, array[20];
      ...
      return 0;
    }

In this function, the variables i, j, and array[] are allocated space
on the stack.

Because of the heap, your program can use more than 512KB and not
crash, provided that you use new to allocate memory.

As to using memory that is already in use by other programs, it's
impossible: Windows runs each program in its own ``virtual machine''
whose address space is totally separated from that of other programs.
You cannot reference the same memory from two different DJGPP
programs, not on Windows.

- Raw text -


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