www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/30/13:55:13

Message-Id: <m0xG0q8-000S1uC@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT edu DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT edu DOT ar>
Organization: INTI
To: djgpp AT delorie DOT com
Date: Tue, 30 Sep 1997 14:58:21 +0000
MIME-Version: 1.0
Subject: Re: Problems with malloc/new

> Gavin Sinclair wrote:
> 
> > With malloc, I was finding that it SOMETIMES fails.  That is, I'd run
> > the exact same executable several times in a row, and about half the
> > time my debugging apparatus (printing to a file) would post-humously
> > report that the pointer I had tried to allocate was 0.
> >
> > Giving up, I used new instead, and now, again about half the time, the
> > entire program fails, saying "Virtual memory exceeded by 'new'".  At
> > least with malloc the program ran!  (With only one side-effect, too).

You are writing out-of the bounds of some of your heap or local variables, with 
it you are destroying the content of some variable that holds the size of the 
block to allocate, or you are using a non-initialized variable as the size of 
the block to allocate. 

Problems like this are hard to track. you can try using some code like MSS 
(http://zipi.fi.upm.es/~a920101/mss/mss.html) to find the problem.

SET
------------------------------------ 0 --------------------------------
Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-sot AT usa DOT net - ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013

- Raw text -


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