CUDA_ERROR_INVALID_DEVICE after playing many times videoDecodeGL

I loop the cudaDecodeGL example to play a list of video.
As the videos may have different format, I use loadVideoSource(), initCudaVideo() and freeCudaResoures() for each video.
After the program play for many times, the program cannot new VideoDecoder and return error message

Is the problem of overheat? As some times the program can run more than 100 times but may also run for a few times and with the error of CUDA_ERROR_INVALID_DEVICE.
It doesn’t seem the problem of memory leakage. I have use memtestG80 and my GeForce GTX 660 is ok.