Memory DebuggingTo enable memory debugging, define the environment variable MS_DEBUGMDLHEAP. In most cases, you will want to set it to the name of your application. If memory debugging is not enabled, MicroStation should run exactly as before. If it is enabled, the performance of MicroStation will suffer in some cases and MicroStation will use more memory.
The following debugging tools are available:
1. When memory is freed, the entire block is set to 1. This should cause catastrophic errors in the MDL application if it continues to use the memory block after freeing it.2. Every block of memory is bracketed by special markers. Both free and realloc check these markers to verify that they are intact. If either marker is corrupted, then MicroStation prints out an error message, the first 20 bytes of the block, the last 16 bytes of the block, and the first 4 bytes after the block. It also aborts the MDL application.3. The MicroStation command MDL HEAP <task ID> causes MicroStation to display a list of blocks that the application has allocated. If MS_DEBUGMDLHEAP is defined, MicroStation also examines the markers on all of the blocks and reports if any are corrupted.4. The MDL debugger command memory also causes MicroStation to display a list of blocks that the application has allocated. If MS_DEBUGMDLHEAP is defined, MicroStation examines the markers on all of the blocks and reports if any are corrupted.5. If the application specified by MS_DEBUGMDLHEAP calls any of the heap management functions (malloc, calloc, realloc or free), then MicroStation examines all of the blocks currently allocated by that application. If MicroStation finds a corrupted marker on any of the blocks, then it displays the relevant data and aborts the application.If MS_DEBUGMDLHEAP is defined, then the first tools 1 through 4 are available. If MS_DEBUGMDLHEAP specifies the task ID of an application, then 5 works for that application. That is, MicroStation scans the application's malloc list on every call to malloc, calloc, realloc and free. If MS_DEBUGMDLHEAP is defined as ALL, then 5 works for all applications.
MicroStation converts the value of MS_DEBUGMDLHEAP to upper case, so the case is not important. If MS_DEBUGMDLHEAP is defined, then MicroStation displays the message MS_DEBUGMDLHEAP is defined as <value> at startup.