Mail Archives: djgpp/1999/10/28/17:09:57
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 -