Skip to content

Out of memory exception  #1370

Open
Open
@rkrgithub

Description

When we execute below code, we are getting below exception from Dapper.SqlMapper.GetTypeDeserializerImpl.
The stored procedure which executing in the code returns just 200 rows within no time.
We are using Dapper v1.50.4.0

Code :

public async Task<ApplicationInstance> GetInstanceByRegistrationAsync(Guid registrationId)
        {
            return await ExecuteQueryAsync(async (conn) =>
            {
                var result = await conn.QueryAsync<ApplicationInstance>($"{Schema}.[sp_GetApplicationInstance]",
                    new { RegistrationRowIdentifier = registrationId }, commandType: CommandType.StoredProcedure);  

                if (result == null)
                {
                    Logger.LogInformation(Events.DataAccess, $"No result found for registration id: {registrationId.ToString()}. {LogEventCorrelation.Message(_correlationId)}");
                    return null;
                }

                Logger.LogInformation(Events.DataAccess, $"Retrieved result for registration id: {registrationId.ToString()}. {LogEventCorrelation.Message(_correlationId)}");

                var instance = result.FirstOrDefault();
                if (instance != null)
                {
                    instance.RegistrationId = registrationId;
                }

                return instance;
            }, _correlationId);
        }

Exception :

System.OutOfMemoryException:
at System.Reflection.Emit.ILGenerator.EnlargeArray (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Reflection.Emit.ILGenerator.EnsureCapacity (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Reflection.Emit.ILGenerator.Emit (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Dapper.SqlMapper.GetTypeDeserializerImpl (Dapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=nullDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: C:\projects\dapper\Dapper\SqlMapper.csDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: 3228)
at Dapper.SqlMapper+TypeDeserializerCache.GetReader (Dapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=nullDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: C:\projects\dapper\Dapper\SqlMapper.TypeDeserializerCache.csDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: 153)
at Dapper.SqlMapper+TypeDeserializerCache.GetReader (Dapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=nullDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: C:\projects\dapper\Dapper\SqlMapper.TypeDeserializerCache.csDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: 50)
at Dapper.SqlMapper.GetDeserializer (Dapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=nullDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: C:\projects\dapper\Dapper\SqlMapper.csDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: 1787)
at Dapper.SqlMapper+d__311.MoveNext (Dapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=nullDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: C:\projects\dapper\Dapper\SqlMapper.Async.csDapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null: 395) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Mobility.Services.Management.Repositories.ApplicationRepository+<>c__DisplayClass13_0+<<GetInstanceByRegistrationAsync>b__0>d.MoveNext (Mobility.Services.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullMobility.Services.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: C:\Build\_work\4\s\src\Mobility.Services.Management\Repositories\ApplicationRepository.csMobility.Services.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 455) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Mobility.Shared.Persistence.SqlRepository1+d__81.MoveNext (Mobility.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Polly.Policy+<>c__DisplayClass120_01+<b__0>d.MoveNext (Polly, Version=5.3.1.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Polly.RetrySyntaxAsync+<>c__DisplayClass21_0+<b__1>d.MoveNext (Polly, Version=5.3.1.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Polly.Retry.RetryEngine+d__11.MoveNext (Polly, Version=5.3.1.0, Culture=neutral, PublicKeyToken=null) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Polly.Retry.RetryEngine+<ImplementationAsync>d__11.MoveNext (Polly, Version=5.3.1.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Polly.Policy+d__1201.MoveNext (Polly, Version=5.3.1.0, Culture=neutral, PublicKeyToken=null) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Mobility.Shared.Application.PollyCircuitBreaker+<ExecuteAsync>d__61.MoveNext (Mobility.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Mobility.Shared.Persistence.SqlRepository1+<ExecuteQueryAsync>d__41.MoveNext (Mobility.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions