Loss frame when CPU usage high

hi, i’m new to OpenCV
I create a thread with while loop of (grab and retrieve) to get image from camera
then found when the CPU usage is high the image start to loss.
there is my while loop code

while (1)
{
	if (!cap.isOpened())
		return CAM_ERROR_OPEN;
	i = 0;
	cap.grab();
	res = cap.retrieve(frame, 0);
	if (res==0) {
		frame_count = frame_count;
		printf("no image\n");
	}
	else {
			if (frame_count > c_depth)
			{
				frame_count = 0;
			}
			printf("%d frame get\n", frame_count);

			///////////////memory copy and split part///////////
			memcpy(img_T, frame.data, c_width * c_height * 2);
			for (size_t i = 0; i < c_total; i = i + 8)
			{
				img_L[(i / 2) + 0] = img_T[i + 3];

				img_L[(i / 2) + 1] = img_T[i + 2];

				img_L[(i / 2) + 2] = img_T[i + 1];

				img_L[(i / 2) + 3] = img_T[i + 0];

				img_R[(i / 2) + 0] = img_T[i + 7];

				img_R[(i / 2) + 1] = img_T[i + 6];

				img_R[(i / 2) + 2] = img_T[i + 5];

				img_R[(i / 2) + 3] = img_T[i + 4];
			}
			mtx.lock();
			memcpy(img_L_T + (frame_count * c_width * c_height), img_L, c_width * c_height);
			memcpy(img_R_T + (frame_count * c_width * c_height), img_R, c_width * c_height);
			frame_count++;
			mtx.unlock();
	}

}