Date: Tue, 11 Nov 1997 12:15:51 +0200 (IST) From: Eli Zaretskii To: John Machin cc: djgpp-workers AT delorie DOT com Subject: Re: malloc() In-Reply-To: <9711102035.AA14775@clio.rice.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Mon, 10 Nov 1997, Charles Sandmann wrote: > > > pathalogical data initialization codes to see how they perform in > > What are these, please? > > There were some examples discussed on the NG/Mailing list about a month > back, in which the initialization of an array with a large number of > elements consumed a huge amount of memory. I would suggest checking the > mailing list archives - I don't remember the details. Here's a source that reveals this problem. Please note that this source causes a lot of allocations, but I'm not sure it also causes a lot of calls to realloc/free. Also note that the actual source is 300K and I didn't want to post it in its entirety. You will have to replicate the lines that initialize the array with your favorite editor or another tool. #include #include unsigned xxx[100000] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, /* there should be 10,000 lines like this */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, }; int main (void) { return printf ("%d\n", xxx[rand() % 3] + xxx[rand() % 4]); }