This is not a bug, but the way a ram preview works in a visual effects and compositing app like After Effects.
AE is not a video editor. It loads each uncompressed frame into memory and starts to play them back. When you run out of memory it starts looping the playback if your preview panel is set to loop playback. In a typical 10 hour production day using After Effects I might run 10 or 20 full-resolution previews of a comp that are 3 or 4 seconds long before I go back to working on the comps. If I am checking motion and animation I run dozens of low resolution, most if not all effects off, sometimes skipping 1 or 2 frame "pencil test" previews of the motion that are the whole length of the shot, but all I am checking is the timing. I will turn on all effects and motion blur and zoom check a few hero frames (critical frames) carefully to make sure I am getting everything I need. Lots of times I do this at a magnification ratio of 400% or more to make sure things are properly up. I call those my Ink and Paint tests. Then I render.
A 3-minute comp in AE is an eternity. I don't know any pros that use AE like this. Your comps should almost always be one-shot trimmed to just the frames that will appear in the final edit, and you should do the editing in an NLE. More than 90% of my comps are under seven seconds. On rare occasions, I will create a sequence in AE that contains several shots but that sequence is never longer than a sentence or phrase of narration or dialogue or a single phrase of music. Trying to edit, even trying to preview 3 or 4-minute comps in AE is a lot like driving nails with a screwdriver. You'll eventually get the job done but it will be painful and the end product will not be as good as it would have been if you had used the right tool.
Agree with Rick. You need to read the online help on how previews in AE actually work.