TdsParserStateObject - disposal? Entity Framework Basics

I am using EF and have a problem with TdsParserStateObject .

I call this method many times:

  public void SaveDataFromERP(string synchronizationType, string xml,int errorsHandlingPercentagePartition) { var param1 = new SqlParameter("XML", SqlDbType.Xml); param1.Value = xml; var param2 = new SqlParameter("PartitionedPackagePercentage", SqlDbType.Int); param2.Value = errorsHandlingPercentagePartition; ((IObjectContextAdapter)this).ObjectContext.ExecuteStoreQuery<dynamic>( $"exec [Synchronization].[Import{synchronizationType}] @XML, @PartitionedPackagePercentage", param1 , param2 ); } 

My repository consists of

 SynchronizationRepository : ISynchronizationRepository { private readonly POSDBContext _context = new POSDBContext(); public void SaveData(string typeName, string xmlFile, int errorsHandlingPartitionPercentage) { _context.SaveData(typeName, xmlFile,errorsHandlingPartitionPercentage); } } 

When I call ExecuteStoreQuery , I can see the new object in the TdsParserStateObject memory.

Unfortunately, I have to repeatedly call this method sequentially (a lot of data). The result is about 60 TdsParserStateObject , and it takes a lot of memory.

In addition, these objects do not disappear after a while.

Can they be disposed of?

enter image description here

+5
source share

Source: https://habr.com/ru/post/1246138/


All Articles