When change the database data, the results of a query or the original data, did not update, Internet to say it's local cache, every time new,
So instead of
Private void Query ()
{
DBContext context=new MyDBContext ();
Do something...
The context. The dispose ();
The context=null;
}
Or
Private void Query ()
{
Using (DBContext context=new MyDBContext ())
{
Do something...
}
}
Can find the data in the database update is normal read here, but the memory leak happened, feeling every time new out of the context is not system recycles it, until the entire program collapse due to excessive memory footprint
Don't know what's the problem, a great god, please grant instruction. Thank you
CodePudding user response:
Only the possibility of recovery is not timely, shall not be recycled mayEF is eaten memory
You can optimize your queries, or in other lightweight framework
CodePudding user response:
when the database data change, the results of a query or the original data,Did you saveChange?
find the data in the database update is to be able to read properly, but the memory leak happened, feeling every time new out of the context is not system recycles it, until the entire program collapse due to excessive memory footprint
Could not recycled, but every time after recycling, you open the ef link more,
In this case, you use Using,
CodePudding user response: