Can't clear internal BLToolKit cache explicitly
Hello, Igor! I have some troubles with reading big data. For example, I do that:
while (true) { objects = dbManager.SetCommand(fullQuery, ...params...).ExecuteList<TImpl>(); }
As you can see, each iteration clears reference on previos data block. GC periodically clears the memory. But after 2 hours proccess takes almost 1Gb RAM! I suppose that readed objects cached in some internal cache of BLTK. Am I right? In EntityFramework this situation resolves by "no tracking changes" flag. Here I have to dispose DBManager every cicle iteration. Is there another way? Some dbManager.ClearCache ? :-)
The ExecuteList method does not cache anything.
Usually GC takes as much memory as it can if other applications do not need it. So, I do not think this is a problem.
It's very strange... Why when I do this:
using (var dbManager = new DBManager())
{
while (true) // ~ 10 millions objects total, 10,000 objects in one iteration
{
objects = dbManager.SetCommand(fullQuery, ...params...).ExecuteList();
}
}
Memory usage grows up to 1Gb (and my app throw OutOfMemoryException), but if I do this:
while (true) // ~ 10 millions objects total, 10,000 objects in one iteration
{
using (var dbManager = new DBManager())
{
objects = dbManager.SetCommand(fullQuery, ...params...).ExecuteList();
}
}
- everything is OK, memory usage fluctuates around the mark of 300Mb ?
i'v done mostly the same test:
static void Main(string[] args)
{
using (var db = new DbManager())
{
for (int i = 0; i < 10000; i++)
{
var e = db.SetCommand("select * from transactiondetail").ExecuteList<Trans>();
}
Console.ReadLine();
}
and have no problem with memory so i think it would be better to look with memory profiler where are the roots for objects (memory leak) in your case
for ex. i'v faced with memory leak by event handlers when cached objects are subscribed to events of "selected" objects
Thanks, i'll try it. By the way, your code creates SAME objects many times. In my case, every ExecuteList selects next page of uniq objects - may be this is important.
mostly it should not mean... but memory profiler should show the truth.
please, tell about results, it is interesting case
What profiler should I use? Standart PerfMonitor?