In modern Operating Systems (that is, anything developed since 1970) this has been the job of the Operating System. While it may appear to the lay observer that duplicating this capability in each and every application programme might lead to lesser unemployment, there is a severe lack of capability to do so and attempts to "do optimization at the wrong level" have always resulted in disaster.