During load testing i found this exception. So why its there there even my REdis server is with 28GB memory and 8vcpu. Even my resources from redis are 40% in use. so how to fix this issue?
Error message:
Exception of type 'System.OutOfMemoryException' was thrown.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.GC.AllocateNewArray(IntPtr typeHandle, Int32 length, GC_ALLOC_FLAGS flags)
at System.GC.1.Rent(Int32 minimumLength)
at System.Text.Json.Utf8JsonWriter.WriteStringEscapeValue(ReadOnlySpan1 value, Int32 firstEscapeIndexVal)
at System.Text.Json.Serialization.Converters.StringConverter.Write(Utf8JsonWriter writer, String value, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.Serialization.JsonConverter1.WriteCoreAsObject(Utf8JsonWriter writer, Object value, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.JsonSerializer.WriteCoreTValue
at System.Text.Json.JsonSerializer.WriteStreamAsyncTValue
at System.Text.Json.JsonSerializer.WriteStreamAsyncTValue
at System.Text.Json.JsonSerializer.WriteStreamAsyncTValue
at Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.
Comment From: mgravell
This isn't a redis/redis issue. It seems to be JSON conversion of your payload on the web server. it isn't really a topic for here, but maybe I can help anyway (I look after SE.Redis and I'm on the aspnet team). What are you storing here? Can we see the C# code? However: anticipate that it gets closed here, because the redis/redis folks can't impact this - it never left the web server. I don't think it hit the SE.Redis library, either, and it certainly didn't hit your redis server.