Fixed important source of memory leak in CUDA.