Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't clear internal BLToolKit cache explicitly #286

Open
TimeCoder opened this issue Dec 20, 2013 · 8 comments
Open

Can't clear internal BLToolKit cache explicitly #286

TimeCoder opened this issue Dec 20, 2013 · 8 comments

Comments

@TimeCoder
Copy link

Hello, Igor!
I have some troubles with reading big data. For example, I do that:

while (true)
{
objects = dbManager.SetCommand(fullQuery, ...params...).ExecuteList();
}

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 ? :-)

@igor-tkachev
Copy link
Owner

The ExecuteList method does not cache anything.

@igor-tkachev
Copy link
Owner

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.

@TimeCoder
Copy link
Author

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 ?

@ili
Copy link
Collaborator

ili commented Dec 24, 2013

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

@TimeCoder
Copy link
Author

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.

@ili
Copy link
Collaborator

ili commented Dec 25, 2013

mostly it should not mean...
but memory profiler should show the truth.

please, tell about results, it is interesting case

@TimeCoder
Copy link
Author

What profiler should I use? Standart PerfMonitor?

@ili
Copy link
Collaborator

ili commented Dec 30, 2013

any .Net memory profiler, i think

dotTrace for ex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants