Dynamic Memory Allocation

SWANGER%AUDUCVAX.BITNET at CUNYVM.CUNY.EDU SWANGER%AUDUCVAX.BITNET at CUNYVM.CUNY.EDU
Tue Mar 29 18:18:27 AEST 1988


I am using Microsoft C 5.0 to write a program for my AT clone (640k) and I am
having problems with dynamic memory allocation.  My program attempts to
dynamically allocate several arrays.  The size of these arrays varies due to
user input.  If the user enters small values, small arrays are allocated.  If
the user enters large values, large arrays are allocated.  I keep running out
of memory when the user enters values that are too large.  There is a point
where if a user enters an integer (say n), the program works correctly.  If
the user runs the program again and enters the next largest integer (n+1),
the program dies for lack of memory.  At first I thought I had reached the
limit of my 640k, but when I ran my program on a 256k machine I was able to
allocate exactly as much memory as I could with 640k.  It seems like there is
memory out there that I am unable to allocate.  I think it has something to
do with the Intel curse of 64k segments (but I may be wrong).  I am compiling
my program with the large memory model, and I am using the calloc(), malloc()
and free() functions to allocate and free this storage.  I've tried using the
halloc() function with little success.  I've read the MSC manuals on this
subject, but I obviously don't understand everything.

I need help.  I would appreciate all suggestions, tips and memory allocation
routines that any of you think may be helpful.


--------------------------------------------------------------------------------

David Swanger
Academic Computing Services
200 L Building
Auburn University, AL  36849
Telephone: 205-826-4813              |-----------------------------------------|
                                     |                                         |
SWANGER at AUDUCVAX  (BITNET address)   |      My opinions are my own ... etc.    |
                                     |                                         |
--------------------------------------------------------------------------------



More information about the Comp.lang.c mailing list