I'm not quite sure what you mean by "detect", but there are surely function calls for each platform that return amount of virtual/physical memory available.