home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!news.bbn.com!noc.near.net!wpi.WPI.EDU!winton!ajb
- From: ajb@winton.uucp (Arthur J. Butler)
- Newsgroups: comp.lang.c++
- Subject: Re: Allocating arrays larger than 64K with new?
- Message-ID: <BsxEsH.Eso@wpi.WPI.EDU>
- Date: 13 Aug 92 14:26:41 GMT
- References: <1992Aug9.152253.11345@newshub.sdsu.edu> <894@nazgul.UUCP> <f94m37_.feustel@netcom.com>
- Sender: news@wpi.WPI.EDU (USENET News System)
- Organization: Worcester Polytechnic Institute, MA
- Lines: 97
- Nntp-Posting-Host: winton.wpi.edu
-
- In article <f94m37_.feustel@netcom.com> feustel@netcom.com (David Feustel) writes:
- >The following program compiles and links successfully with the ZTC
- >-mx option. Running the program crashes the system. The program was
- >linked and run under Flashtek's x32 dos extender.
- >
- >==============
- >
- >#include <stdio.h>
- >
- >#define AS 3000000
- >
- >long * getspace(unsigned int amount)
- >{ long * a;
- > printf("malloc %d ",amount);
- > if(a=(long *) malloc(sizeof(long)*amount))
- > { printf("succeeded\n");
- >
- > else
- >
- > { printf("failed\n");
- >
- > }
- >
- > return a;
- >
- >}
- >
- >
- >
- >
- >
- >void main(int argc,char **argv)
- >
- >{ long i,imax=AS;
- >
- > double sum=0;
- >
- > long *a, *b, *c;
- >
- > printf("Hello, World\n");
- >
- > for(i=0;i<argc;++i)
- >
- > { printf("%s\n",argv[i]);
- >
- > }
- >
- > a=getspace(AS);
- >
- > b=getspace(AS);
- >
- > c=getspace(AS);
- >
- > if (a==0|b==0|c==0) exit(-1);
- >
- > for(i=0;i<imax;++i)
- >
- > {
- >
- > a[i]=i*i;
- >
- > b[i]=i;
- >
- > c[i]=i*i*i;
- >
- > sum+=a[i]+b[i]+c[i];
- >
- > }
- >
- > free(a); free(b); free(c);
- >
- > printf("sum: %e\n",sum);
- >
- > exit(0);
- >
- >}
- >
- >
- >--
- >Dave Feustel N9MYI <feustel@netcom.com>
- >---
- >Given Civil Seizure, from the DEA's point of view, winning the War on
- >Drugs would be killing the Goose that lays golden eggs.
-
-
- I just compiled this using Zortech and linking with x32v.lib. I
- compiled it both as a C program and as a C++ program (minor note: i had to
- include stdlib.h). I sucessfully ran it on my 486 with 8 meg of
- memory and about 80 meg of free disk space. You are allocating three
- chunks of 12 Mbytes each.
-
- I believe your problem is that you compiled the program in small
- memory model and not X memory model. It will link with x32 and not
- complain at all. I did that by mistake and indeed running the program
- halted the system.
-
- arthur (ajb@winton.wpi.edu)
-