Fix for memory issue with C++ interface

A little while ago, we ran into a significant memory issue found by an OpenMatrix user. It had to do with a C++ toolbox written using the newer, binary-compatible interface (OMLInterface, etc).

It took a lot of effort to find the issue, but it turns out that it all of the Interface handles were the problem. The user’s function was being called many, many times in an optimization routine and even thought the individual leaks were tiny, they added up due to the high number of calls.

At first, I was planning to add a Release method to all of the interface objects, but that would need to be called by the user. Some people thought that would make the interface too difficult to use.

So in the end I settled on a garbage collection technique. This change has been tested with the user’s problem and it dropped the memory usage on a sample problem from 4 GB to 80 MB.

I merged this fix into the master branch yesterday. Thanks to Brian and Bill for their help.