I'm using EF and have problem with TdsParserStateObject
.
I'm calling 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 new object in memory TdsParserStateObject
.
Unfortunately I must call this method in sequence many times(a lot of data). The result is about 60 TdsParserStateObject
and it take a lot of memory.
Moreover these objects do not disappear after some time.
Is it possible to dispose them ?
Resolved my own issue to some degree by removing:
"MultipleActiveResultSets=True"
From my connection string. My connections were being made on background threads so this goes someway to explaining why I was seeing the increase:
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql/enabling-multiple-active-result-sets
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With