U4-10815 - Make DisposableObjectSlim

Created by Shannon Deminick 10 Jan 2018, 01:58:01 Updated by Shannon Deminick 12 Jan 2018, 01:44:02

Tags: Unscheduled

Subtask of: U4-9432

As it turns out our DisposableObject used implemented the IDisposable pattern recommended quite some time ago which includes defining a finalizer, in recent times it's noted that this is a bad thing to do if you don't need a finalizer, even if you are calling GC.SupressFinalize, here's a great writup with links to the new IDisposable pattern docs: https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/89940-stay-away-from-umbracocoredisposableobject

In (IIRC) all cases in Umbraco we aren't using any unmanaged resources so we don't need a finalizer at all. We should create a new DisposableObjectSlim which does the same thing as DisposableObject but without the finalizer pattern and use that for all of our objects. In theory this should speed things up.


Robert Copilau 10 Jan 2018, 12:59:42

PR: https://github.com/umbraco/Umbraco-CMS/pull/2380


  • Made a slim version of DisposableObject, which means I had to remove the unneeded finalizer.
  • Replaced all usages of the DisposableObject with the slim version.

Robert Copilau 11 Jan 2018, 10:13:24

Some cleanup : https://github.com/umbraco/Umbraco-CMS/pull/2380/commits/928426942893d248b0f0cb0a865f9ae469106e8f

Robert Copilau 11 Jan 2018, 12:35:52

Reverted DisposableObject: https://github.com/umbraco/Umbraco-CMS/pull/2380/commits/e26cbccfe0a0d952699c22f9ac33d8d7da91dceb

Priority: Normal

Type: Task

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.8.0

Sprint: Sprint 76

Story Points: 0.5

Cycle: 7