Re #8361. Move heap allocation after ParameterReference creation.

The ParameterReference constructor can throw, which was leaking the
new'd double.
Re #8361. Fix memory leaks seen when calling copying a Sample.

The copied Surface objects in the Object were being leaked as it seems
the correct way to fill the surface list is with existing Surface
objects held within the 'TopRule' member.
Merge branch 'bugfix/8361_api_memory_leaks' into develop