Date: Thu, 7 Nov 1996 16:27:44 +0200 (IST) From: Eli Zaretskii To: "John M. Aldrich" Cc: DR TE$TH & THE ELECTRIC MAYHEM , djgpp AT delorie DOT com Subject: Re: max=32768 pointers? In-Reply-To: <327FF9A5.1D0D@cs.com> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 5 Nov 1996, John M. Aldrich wrote: > DR TE$TH & THE ELECTRIC MAYHEM wrote: > > > > I have heard that you cannot allocate 32,768+ pointers without first freeing > > some of them. Is this true? If so, what is the cause? I could probably > > figure a workaround if I knew what was stonewalling me. > > your memory requirements. The absolute upper limit you should observe > is no more than 200 or so separate allocations; any more and you're > doing something badly wrong. Both of the numbers above (32,768 and 200) are in general incorrect. First, any such discussion is specific to a certain DPMI host. If we are talking about CWSDPMI, then the latest release 3 is documented to be able to allocate at least 21MBytes in small chunks; the small test program below allocates about 28MBytes in 1KB chunks before `calloc' fails. I changed the chunk size to 500 bytes, and was able to allocate at least 40,000 such chunks. So you don't need to worry about any limits as long as you don't allocate more than 20MBytes; changing the default parameters of CWSDPMI with CWSPARAM can push that limit still further. Btw, QDPMI let me allocate 80MBytes in 2KB chunks (on a 64MB machine) and never puked. ------------------------------ alloctst.c -------------------------------- #include #include int main(void) { char *ptable[40000]; int imax = sizeof (ptable) / sizeof (ptable[0]); int i = 0; while (i < imax) { ptable[i] = (char *) calloc (1000, 1); if (!ptable[i]) break; printf ("Alloced %d buffers\n", ++i); } return 0; }