Automating heterogeneous memory management