I would like to change the frequency of the RPI, how can I do that, I'm using low level programming. Also how can I get the used memory and free memory?
To get the memory usage, try the following command, this will give you usage in MB.
Are you referring to the SOC frequency? It currently cannot be set dynamically (while the RPi is on). But there should be a firmware update sometime soon, that enables this. Keep an eye out for it. If your speaking not dynamically, then the overclock values can be changed in the /boot/config.txt file. Refer to this link