You are trying to use After Effects like it was a Non Linear Editor. It's not. You ran out of ram because you don't have enough installed to playback the entire ram preview. Simple as that. The solution is to set your Composition Panel resolution to "Auto" and then set the Zoom Factor to 50% or 25%, or set the Preview Panel to playback every other frame. Until Adobe changes the rendering engine in After Effects you'll have to get used to previewing short segments or previewing at lower resolutions.
Don't try and learn AE by just diving into a few tutorials, start with the Basic Workflow and then move on from there.