Android runs on Linux, not on Windows. Unused RAM is wasted RAM. (And there's no pagefile in Linux.) When Android needs space for an app you want to run, it'll kill the least recently used app.
If you're using an old (2 years or more) phone, with less than 1GB of RAM, you'll be running out of RAM a lot, because a lot of the current apps are written for phones with larger amounts of RAM. There's nothing you can do about it but run older versions of the apps or get a newer phone.