www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/09/03:46:21

Message-ID: <316A22DD.53D1@matrust.es>
Date: Tue, 09 Apr 1996 09:42:05 +0100
From: Jesus Canal <jesus AT matrust DOT es>
Organization: Digital Illusion (Grup Matrust)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: malloc crash

Hi everyone !

Last weekend, I wrote a program that crashed when creating an object
of my own ZBuffer class.

After debugging it, I realized the problem was memory allocation.

Here it is a simple program with the same results. Running the program
on my machine, it crashes after 1027 iterations. The message is:

   Exiting due to signal SIGSEGV

I think it is neither a virtual memory problem (the message would be
"Virtual memory exceeded in `new'"), nor memory initialization (the
program only allocates memory, does not use it). 

Could someone explain why this program crashes ?


/*** SOURCE CODE *************************/

#include <stdio.h>
#include <stdlib.h>

void main ()
{
   int   i;

   for (i = 0; i < 5000; i++)
   {
      malloc (10000);
      printf ("%d\n", i);
   }
}

/*****************************************/


I am using:    DJGPP v2.0
               CWSDPMI V0.90+ (r1)
      on a:    486 DX2 66 MHz (8 MB)

Thanks in advance.

Jesus.

--------------------------------------------------------------------------------
                                                DIGITAL ILLUSION * Grup Matrust
      Jesus Canal             Trav. de les Corts, 222 * 08028 Barcelona (Spain)
   Software Enginner               Tel. (34-3) 409 01 15 * Fax (34-3) 409 01 16
                                 email: jesus AT matrust DOT es * http: www.matrust.es
--------------------------------------------------------------------------------

- Raw text -


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