www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/10/04:15:31

Message-ID: <316B7A47.381F@matrust.es>
Date: Wed, 10 Apr 1996 10:07:19 +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: Re: malloc crash
References: <199604100421 DOT AA172870100 AT relay1 DOT geis DOT com>

j DOT aldrich6 AT genie DOT com wrote:
> 
> Reply to message 5073138    from JESUS AT MATRUST on 04/09/96  4:42AM
> 
> >  for (i = 0; i < 5000; i++)
> >  {
> >     malloc (10000);
> >     printf ("%d\n", i);
> >  }
> 
> This may not be your problem, but shouldn't you test to see if malloc() fails
> before continuing in your loop?  Allocating fifty (or even ten) megabytes of
> memory is hardly a guaranteed proposition.
> 
> On the other hand, I can see no reason why malloc would cause a crash if
> it ran out of memory...


You are right John. I should test to see if malloc () fails. I do so in the
radiosity program I'm developing and it crashes. That's not the problem.

The simple/sample program I posted it's the minimum number of instructions to
generate the error (not a way to allocating memory).

Thanks for your answer.

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