cudaGraphicsGLRegisterImage fail and return code=2 (cudaErrorMemoryAllocation), why or how to debug this?

cudaGraphicsGLRegisterImage fail and return code=2 (cudaErrorMemoryAllocation), why or how to debug this? thanks!