Mail Archives: djgpp/1998/06/28/09:26:39
From: | "John M. Aldrich" <fighteer AT cs DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Malloc problem.
|
Date: | Fri, 26 Jun 1998 20:47:50 -0400
|
Organization: | Two pounds of chaos and a pinch of salt.
|
Lines: | 37
|
Message-ID: | <35944136.427BAEE6@cs.com>
|
References: | <35939F88 DOT 5F0C AT sentex DOT net>
|
NNTP-Posting-Host: | ppp119.cs.net
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
temujin AT sentex DOT net wrote:
>
> I have a structure A which is 48 bytes.
> In one function 550 A's get created with Malloc() and then when that
> function exits and I try to malloc 5 bytes I get a General protection
> fault, or when I try more then 500 I seem to get this problem of being
> unable to use malloc. BUT my program will work perfectly fine when the
> number of A's does not exceed 500. Is there some restriction on the
> number of Malloc's you can use at a time?
If you are using an older version of cwsdpmi.exe (version 1 or 2), then
you may be running into a limitation on the number of simultaneous
memory blocks that can be allocated at any one time. The easiest
solution is to upgrade to cwspdmi version 4 and try that.
If you already have cwsdpmi r4, or are running your program under a
Windows (3.1/95) DOS box, then I'm not sure what the problem is. Make
sure that you have enough free memory by running 'go32-v2' before you
run your program. If the values it displays are very low (under 16 MB
total), then you may need to increase the available DPMI memory for DOS
programs.
Another thought: if you are storing the addresses returned by malloc()
in an array, make sure that you are not overflowing its bounds. That
could trash things very easily.
If all else fails, post enough code from your program to allow us to
reproduce the crash ourselves (including the struct definition) and
we'll see if we can figure it out.
--
---------------------------------------------------------------------
| John M. Aldrich | "If 'everybody knows' such-and-such, |
| aka Fighteer I | then it ain't so, by at least ten |
| mailto:fighteer AT cs DOT com | thousand to one." |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -