Disposal in HPRM 82

Good and bad news

In an earlier post I discussed when and what to Dispose when using the .Net SDK.  The good news in HPRM 82 is that disposal is much simplified.  The bad news is that it is a breaking change from previous versions.

What to dispose

There are now only two objects that require disposal, they are Database and DocumentStream.

What not to dispose

Previously it was required that you dispose TrimMainObjectSearch and most other objects could be disposed, even though this had no actual effect.  In HPRM 82 the 'IDisposable' interface has been removed from all objects other than those that require disposal (i.e. Database and DocumentStream).  This will require you to edit and re-compile any .Net SDK that calls Dispose unnecessarily.


Why did we cause you this pain you may ask?  The primary reason was to assist both our and your development teams to write quality software.  In the previous model there were many classes that implemented IDisposable but only a few that really needed disposal, this made it easy to feel like you had done the right thing when in fact you had overlooked disposal on the one object that really required it. One example of this problem is our use of static code analysis tools such as Coverity to help us find problems in our code.  The vast number of unnecessary Dispose implementations leads to a vast number of false positive errors and a decreased likelihood of us spotting the actual errors.

Written on July 6, 2015