SQL Server hitting System.OutOfMemoryException but server has 10GB free
That exception usually doesn't refer to the SQL Server itself running out of memory, but instead the client workstation that is processing the results running out of memory.

You will generally see this if you are outputting a very large result set into the Output window.

To troubleshoot the issue (and possibly resolve it) allow SQL to write the results to a file rather than trying to put it all in the output window.