-
memory question
i want to know how i create a dynamic matrix but i want to alloc it on the ram not the heap
here's some the code i have:
Code:
#include <iostream.h>
#include <conio.h>
void main (void)
{
int **m;
m = new int *[3];
for (int i=0; i<3;i++)
m[i]=new int [4];
for (i=0; i<3;i++)
delete [] m[i];
delete [] m;
}
if i create a big matrix like 1000x1000 i run out of memory help me plz....
-
You are only allowed to access up to 1024 KB in real mode. Also, DOS will limit that to 640KB. The only way to gain more is to either move to protected mode or to access more memory via HIMEM.SYS (XMS) or EMM386.EXE (EMS).
Protected mode is the easiest, but second to that is EMS. EMS is very simple to use. Check out an interrupt listing for more information about how to use either EMS or XMS. Ralf Brown's interrupt listing is great.
http://www-2.cs.cmu.edu/~ralf/files.html
-
Why would you need to have it specifically on the RAM. What's the difference between that and the heap?
-
as i belive...
heap in c++ (under DOS) is the first 640 kB and i got to alloc about 5mb, so i ran out of memory (i can't alloc everything i need), and also i can't make new dynamic variables...
must be a way to alloc a lot of memory i need at least 5mb...
-
hey try this code....
Code:
#include <iostream.h>
#include <conio.h>
#include <string.h>
void main (void)
{
int **m;
m = new int *[1000];
for (int i=0; i<1000;i++)
m[i]=new int [1000];
char *test = new char[30];
strcpy(test, "This won't work!")
//as you see i can't ask for more memory and the "m" isn't 1000x1000
// i there must be a way to do that...
for (i=0; i<1000;i++)
delete [] m[i];
delete [] m;
}
this question is to fill the matrix with getpixel()... is for make something like a virtual screen....
-
I just told you how to do it. Use EMS.
-
sorry, but i didn't understand how the files in the url you toll me works...