Microsoft KB Archive/37201

{|
 * width="100%"|

PRB: Memory Allocation Error When Using halloc or malloc

 * }

Q37201

5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg kbprb -- The information in this article applies to: - The C Run-time (CRT), included with: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SYMPTOMS ======== While 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. CAUSE ===== Your 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. RESOLUTION ========== You 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 KBCategory: kbprg kbprb KBSubcategory: CRTIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT