Not sure why all these includes were missing, but it's breaking builds for some users: https://bugs.gentoo.org/show_bug.cgi?id=652142 (Added to all files with a reference to std::unique_ptr)
Backport of core PR12859:
This has been heavily adapted to our codebase.
I grepped all the units (.h and .cpp) including memory, the ones using
std_unique_ptr and used the diff to track down the needed inclusions.