I've begun twiddling with VS2005's memory state functions ( _CrtMemState ) to compare memory usage in an attempt to convince myself that my tools do/do not have memory leak issues. I get random occurrences of MicroStation crashes as I develop/test tools.
As a start, In a simple tool with MdlMain() and a keyin command to launch a tool, I create a memory checkpoint ( _CrtMemCheckPoint() ) as soon as MdlMain() is entered and just before it finishes. Then a comparison is made ( _CrtMemDifferences() ). This comparison show things are OK (no differences found). Next I "unload" the app and again check the memory state (compare memory as MdlMain() is completed with the memory as found in my unload function). Again, no differences are found.
Finally, I repeat the test, this time by calling my skeleton MstnElementSetTool via a keyin (so the sequence is "mdl load myapp"; "myapp start mytool"; "mdl unload myapp") but this time, when the memory comparison is done in the unload function, a difference IS found ( reports "256 bytes in 1 Normal Blocks" ). Is there something that should be done to "release" the memory the MstnElementSetTool uses that maybe I'm not aware of and not performing?