Just be aware that in_memory doesn't always mean in memory. I know, why label something "in_memory" if it doesn't mean it will always be in memory? If you are running a script outside of ArcGIS Desktop (ArcMap or Pro), then it is actually in memory. If you run a script from the interactive Python window or a script tool within ArcGIS Desktop, sometimes the output is actually a temporary data set on disk.
For example, with some tools like Create Table and Create Feature Class, in_memory will output to disk if "Background Processing" is enabled:
>>> tbl = arcpy.CreateTable_management("in_memory","test_table")
Although a bit dated, most of the information from blogs posts I wrote a few years ago still applies to ArcMap today: