Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: djgpp AT delorie DOT com Date: Tue, 30 Sep 1997 14:58:21 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Problems with malloc/new Precedence: bulk > 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