delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/04/20:56:18

From: GAMMELJL AT SLU DOT EDU
Date: Wed, 04 Feb 1998 18:15:24 -0600 (CST)
Subject: problem with 'new' in plain DOS
To: djgpp AT delorie DOT com
Message-id: <01IT6WBFNODYC5983X@SLU.EDU>
Organization: SAINT LOUIS UNIVERSITY St. Louis, MO
MIME-version: 1.0

//    There is a problem with the 'new' operator when runnning in plain DOS
//mode (press F8 after "starting windows95 appears and select option 6)
//even when plenty of memory (but no swap space) has been made available
//by adding NOVCPI after NOEMS in c:\config.sys and answering the querys
//in c:\djgpp\bin\cwsparam with "",0,512,3840,2048,32760,0 (only the "" and
//2048 have been changed from the answers in the original djgpp package).
//    While my machine has 128 mb of RAM it should be possible to reproduce
//this problem on machines with less RAM by replacing the 2048 by 1024
//(for machines with 64 mb of ram) or 512 (for machines with 32 mb of
//ram).
//    The memory used is
//             zsize3*zsize2*zsize1*4  bytes
//where 4 is the length of an unsigned integer.  To convert bytes to
//megabytes (mb) divide by 1024^2.
//    One finds the actual available memory by increasing zsize1 and
//zsize2 (I use zsize1=zsize2) until "virtual memory exceeded in 'new'
//occurs at run time.
//    For zsize3=2^n, the actual available memory drops to 1/2
//of the available memory reported by go32-v2.
//    For zsize3=(2^n) - 1, the actual available memory is close
//to the available memory reported by go32-v2.  

//Note: the cwsdpmi.swp file must be disabled and no reference to
//smartdrv.exe may occur in autoexec.bat, otherwise other (as yet
//unresolved) problems prevent access to anything close to the available
//memory reported by go32-v2.

//Since no swap space is provided "virtual memory exceeded in 'new'"
//="out of memory".

//I do not know whether there is a similar problem with 2-dimensional
//arrays or not but I assume there is.

#include <iostream.h>
                          //notation: a,b means zsize3=a and zsize2=zsize1=b
const int zsize3=127;     //127,501 ok (121.601 mb)
                          //127,502 out of memory (122.087 mb)
const int zsize2=501;     //128,356 out of memory (61.882 mb)
const int zsize1=501;     //128,355 (61.535 mb) ok

main()
{int i,j;

     unsigned int * * *m;
     m= new unsigned int * * [zsize1];      
     for (i=0;i<zsize1;i++)
       {m[i] = new unsigned int * [zsize2];  
        for (j=0;j<zsize2;j++)
          {m[i][j] = new unsigned int [zsize3];}
       }

  cout<<"ok"<<'\n';
  return 0;
}

- Raw text -


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