PRB: Memory Allocation Error When Using halloc() or malloc()Last reviewed: July 17, 1997Article ID: Q37201 |
5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50
MS-DOS | WINDOWSkbprg kbprb
The information in this article applies to:
SYMPTOMSWhile running a program you have created with Microsoft C that uses halloc() or malloc(), MS-DOS may print the following message:
Memory Allocation Error Cannot Load COMMAND.COM.You are able to allocate, use, write, read, and free memory, but when your program finishes, you receive the error.
CAUSEYour program is probably writing outside of a memory block you allocated using halloc() or malloc(). MS-DOS maintains information about memory usage in blocks immediately preceding the memory given by halloc(). There is also a header following each entry in the heap. The error is usually a result of overwriting these information blocks and headers. The solution is to find out where the program is overwriting memory and correct it.
RESOLUTIONYou can determine which part(s) of the program overwrites the memory by using CodeView to set a tracepoint or a breakpoint on the memory in question. If you don't have enough memory to run CodeView, you can narrow down the problem by using a pointer to check those bytes at selected points in your program.
|
Additional reference words: 1.00 1.50 5.10 6.00 6.00a 6.00ax 7.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |