PBO and Out of memory

Hi,
I am trying to create the PBO and I get the Runtime API error: out of memory. I figured out the problem is with the cudaGraphicsGLRegisterBuffer.

cutilSafeCall(cudaGraphicsGLRegisterBuffer(&cuda_pbo_resource, gl_PBO,
cudaGraphicsMapFlagsWriteDiscard));

The above line is causing the error. If the image is too big then I should be getting an error at cudaMallocArray which I am not. Can you please help me why I am getting this error?

Thank you.