with 5 you allocate memory for 5 images. With 500 you allocate a ringbuffer for 500 images. This is a lot of memory if you use 640*480*24bit images. But you will be able to store 33,33 seconds of video in memory at 15 frames per second, until the grabber starts to overwrite the buffers from the first one.
The memory buffer is a ringbuffer. This means, that all elements of the ring buffer a filled with image data sequentially. If the last element is reached, the grabber starts at the first memory buffer again. (If it is not locked.)