Merge remote-tracking branch 'origin/bugfix/8357_api_test_memory_leaks'
Re #8361. Fix memory leak by ensuring temporary array is deleted.
Re #8361. Ensure temporary heap-allocated object is deleted.
Re #8361. Delete instantiator in case of an exception being thrown.

The factory takes ownership of the injected instantiator object so is
responsible for deleting it if an exception is going to be thrown and
the algorithm will not end up being subscribed.
Re #8361. No need to check for a null pointer before calling delete.
Merge branch 'bugfix/8361_api_memory_leaks' into develop