If you don't have enough memory, you have two choices.
First choice is to use the disk as buffer, if you have any, this is simple, but if your disk is flash based you'll be wearing it down for no reason.
Second choice is to compress. If you don't need PCM you can encode it as MP3. If you need PCM, there might be other choices. Sound is very redundant and should be quite compressible, even losslessly. But sooner or later you'll reach a limit of your RAM.