Regarding the codecs, usually codecs are used to codify a large media file into one smaller media file.
For instance, you use a codec to convert a 9.6GB DVD into a 700MB avi file. In order to view the file in WMP you have to install de proper decoder, if not WMP won't know how to decode the avi file.
It's the same thing with mp3, you use the mp3 codec to convert WAV files, much larger files 40MB at least, to mp3 files, moreless 6MB.
Regarding the memory question there are three levels of memory:
cache - a very fast , and consequently more expensive, type of memory. It's directly connected to the CPU. It stores the most used instructions in a given period.
RAM - it slower than cache type memory but it's quicker than hdd access, it remains between cache and hdd paging files.
hdd paging files - are stored in your hdd, it contains the less used instructions in a given period.
For instance consider a program that reads several numbers from a file, multiplies all numbers two and then stores the new numbers in the file again, in the period when the numbers are being read from the file, the instruction of reading a number from the file and the instruction of storing it in a variable will be stored in cache, which makes sense because these instructions will be ran as much as the numbers stored in the file so the cpu shall have access to these instructions as quick as possible. The instructions of multiplying by two and the instruction to store a new number in the file will be stored in RAM since in this period of running the program these instructions won't be used.
If you have the patience read this
article in wikipedia.