TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: THOMAS J. PEDERSEN
from: KURT KUZBA
date: 1998-05-13 06:41:00
subject: memory allocation

TJ>   When I compile this (and p> 40) , I get the error message
TJ>   "Too much global data".
TJ>   If I remove the static, and initialize the arrays myself,
TJ>   I get the message
TJ>   "_Limit exceeds 64K"  or  "Abnormal program termination "
TJ>   Obviously, the size of the arrays exceeds a predefined
TJ>   limit  ??.
TJ>   How do I make this work ??
TJ>   #define p 40
TJ>   main()
TJ>   {
TJ>         static  double tabel[p];
TJ>         static  double Umat[p][p];
TJ>         static  double Dmat[p][p];
TJ>         static  double Vmat[p][p];
TJ>         static  double Vtmat[p][p];
TJ>         static  double sigma[p][p];
TJ>   return 0;
TJ>   }
   You will have to use dynamic allocation. Your program is only
   allowed so much memory, and the rest belongs to the OS. You
   have to politely ask the OS for some of it's memory, and then
   be sure to return it when you are done with it.
#define p 40
int main()
{
   double *tabel = new double[p];
   double **Umat = new double*[p];
   double **Dmat = new double*[p];
   double **Vmat = new double*[p];
   double **Vtmat = new double*[p];
   double **sigma = new double*[p];
   for(int ndx = 0; ndx < p; ndx++)
   {
      Umat[ndx] = new double[p];
      Dmat[ndx] = new double[p];
      Vmat[ndx] = new double[p];
      VTmat[ndx] = new double[p];
      sigma[ndx] = new double[p];
   }
   for(ndx = 0; ndx < p; ndx++)
   {
      delete []Umat[ndx];
      delete []Dmat[ndx];
      delete []Vmat[ndx];
      delete []VTmat[ndx];
      delete []sigma[ndx];
   }
   delete []tabel;
   delete []Umat;
   delete []Dmat;
   delete []Vmat;
   delete []Vtmat;
   delete []sigma;
  return 0;
}
> ] Facts are unnecessary encumberance to Truth  -  Joan D'Arc..
---
---------------
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)

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