Which is what OSes implemented in system languages with automatic memory management usually do, it is an OS service.
Oberon example,
https://people.inf.ethz.ch/wirth/ProjectOberon/Sources/Kerne...
Active Oberon example,
https://github.com/btreut/a2/blob/master/source/GarbageColle...
Bare metal Java, Go, .NET, Erlang, OCaml,... with bare metal deployments naturally have the runtime take the OS role.
Smalltalk: https://github.com/pavel-krivanek/BarePharo