Why my cudaMalloc function failed?

Dear all,

My code is like this:

struct Rect


		int Width;

		int Height;


struct RectList


		Rect* vRect;


int main()


		int ListNum = 10;

		RectList* vRectList = NULL;

		cudaMalloc( (void**)&vRectList, ListNum*sizeof(RectList));

		for ( int i=0; i<ListNum; i++ )


				cudaMalloc( (void**)&(vRectList[i].vRect), 20 * sizeof(Rect) );



		return 0;


The program crashed in the for loop. Could you please tell me why?

My card is GeForce 8800 GTX, developed under Visual C++ 2008, CUDA 3.0

Thanks a lot!


You cannot deference vRectList in host memory once it has been allocated in device memory - it is not a valid host pointer.