I found a major memory leak in the Linkage program. Fortunately, the leak only added up to large amounts of memory if a simulation was running for a while.
The leak was caused by my forgetting to create a virtual destructor for a C++ class. One of the changes that I made a few months ago before taking a break from working on this program was to place all rendering code inside of some C++ classes. I opted to use the regular GDI code as the basis for this rendering class instead of making it something that can be used cross platform but it still has the ability to convert any drawing operation from a GDI call to a call to some other functions. For instance, I use this rendering code to “draw” DXF files.
One thing I did with the structure of the program was to have a rendering class that contains a member object that is the actual renderer. When a rendering class is constructed, it accepts a parameter that indicates what type of final rendering is needed. The contained rendering class is based on a common base class so that the higher level renderer does not know or care what type of actual rendering is going on. The high level class is used just to hold the actual renderer and pass on requests to it.
So the bug was that I forgot to make the destructor of the base implementation class a virtual destructor. The destructor for the actual low level rendering class never got call and never cleaned itself up.
I wish that the compiler could have told me this.
I will upload a new installer for the Linkage program shortly.
I need to add that I created a linkage that caused the program to do something wrong and that in turn caused the entire system to become unstable. I think the problem was that I used up a critical and limited resource when I didn’t free things properly. I hope that the problem is gone now that I found the leak.
I am searching the code for other less obvious memory leaks but so far, it looks good. If anything is leaking, it is very very small.
Dave