The CudaSurface class disposes of the CudaArray3D even when an array is passed to the constructor. There should be a concept of ownership, much like you implemented for the CudaArray3D class, as there are instances when you don't want to dispose of the underlying volume when you no longer need the surface.
P.S. I digress, but please take a look at the suggestion I made in my "unified memory" post for how to make those classes generic without sacrificing performance.
The CudaSurface class disposes of the CudaArray3D even when an array is passed to the constructor. There should be a concept of ownership, much like you implemented for the CudaArray3D class, as there are instances when you don't want to dispose of the underlying volume when you no longer need the surface.
P.S. I digress, but please take a look at the suggestion I made in my "unified memory" post for how to make those classes generic without sacrificing performance.