There is insufficient system memory in resource pool 'default' to run this query. on sql
SQL Server will start with as much memory as needed, then slowly ramp up until it uses all allocated to it in the Server Properties:
It will not release any of this memory until the service is restarted; this is by design.
It is generally recommended to leave 2ish GB for the OS, and you need to be mindful of any other processing running on the same server as SQL. It is usually recommended to have SQL Server on it's own server without anything else running there.
That said, 1.5 GB of RAM for SQL Server isn't that much. If you don't have more available, it may be time to add some or upgrade the server.
See also: Technet, Brent Ozar
I am posting this answer because someone may find it useful.
You can set max server memory
even with this query:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'max server memory', 32768; -- for 32 GB
GO
RECONFIGURE;
GO
Also you can use this query to release memory without restarting the service simply by setting to 2 GB (2048) and changing again back to 32 GB (32768) or to the value you want.
Please, do not set it below 1 GB because it will cause errors executing queries and therefore you will need to restart the service to be able to execute queries, even this query to increase memory again.
In our case it was because of Memory Optimized table types, with huge amount of data. There was multiple calls to different stored procedures at the same time and each using the same table type and loading huge amount of records in it (>100,000). For our application, there was way to reduce the number of records inserted in to memory optimized table type i.e. instead if storing all selected items in a memory optimized table type we conditionally stored only the non-selected records.
CREATE TYPE [TestType] AS TABLE (
[TestOrder] VARCHAR (1500) NOT NULL,
[TestDepartment] UNIQUEIDENTIFIER NULL,
[TestCourse] UNIQUEIDENTIFIER NULL,
[TestStudent] UNIQUEIDENTIFIER NULL,
INDEX IX_Test NONCLUSTERED (TestOrder))
WITH (MEMORY_OPTIMIZED = ON);