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

[Question] Memory leak in Join method #87

Closed
MakarovSoftware opened this issue Jun 1, 2017 · 16 comments
Closed

[Question] Memory leak in Join method #87

MakarovSoftware opened this issue Jun 1, 2017 · 16 comments
Assignees
Labels

Comments

@MakarovSoftware
Copy link

Just for test take first test method (Join()), and run it several times (10 000, 100 000, etc.), like this. And every next iteration will take a little bit longer to pass through + we'll get memory leaks. For example, first time it will take about 00:00:00.003, And on 12000 iteration it will take 00:00:00.101 already. On iteration 27400 it will take 00:00:00.214 and so on..

But it's on a small data. In a real project (in my case), for example every next Join gets about 5sec longer:
1 iteration = 3.7 sec
2 iteration = 8 sec
3 iteration = 13 sec
4 iteration = 19 sec.

And now it's a critical bug for me. I think that there is some problems with static cache.

@StefH
Copy link
Collaborator

StefH commented Jun 1, 2017

Maybe related to #84 ?

@MakarovSoftware
Copy link
Author

Yep, I thought about it, but I'm not sure. Anyway, please, fix this ASAP :)) Thank you!

@StefH StefH added the question label Jun 1, 2017
@StefH
Copy link
Collaborator

StefH commented Jun 1, 2017

Please test latest NuGet version1.0.7.3

@StefH StefH self-assigned this Jun 1, 2017
@MakarovSoftware
Copy link
Author

MakarovSoftware commented Jun 2, 2017

Thank you, I've tested it now. Now it soo much better, but still leaks:

1 iteration = 0.95 sec (fantastic!)
2 iteration = 1.4 sec
3 iteration = 1.9 sec
4 iteration = 2.4 sec
5 iteration = 2.98 sec
36 iteration = 21 sec

Well, here in every iteration I work wit exactly the same classes, that connected together through lots of JOINs, it's all the same, but I change just a condition of WHERE statement from iteration to iteration. Hope, this will help.

@StefH
Copy link
Collaborator

StefH commented Jun 2, 2017

Can you add this example project on github? That makes it easier for me to analyse and debug.

@MakarovSoftware
Copy link
Author

The problem is that it's not an example project, I tell you timers from real app and it uses big data with lot's of JOINS, and of course, I can't upload it. But ok, I'll try to make some demo test for this case

@MakarovSoftware
Copy link
Author

Hi! I've made some demo, try to download source from my repo on github, dunno if I done everything right. There is a simple console app, and you could see the growth of time and memory :) Looking forward to your answer!

StefH added a commit that referenced this issue Jun 6, 2017
StefH added a commit that referenced this issue Jun 6, 2017
@StefH
Copy link
Collaborator

StefH commented Jun 6, 2017

Are you sure you have tested the latest version : 1.0.7.3 ?

Because when I run your example, I see this:

press key to run
 0 - 251
10 - 6
20 - 8
30 - 4
40 - 3
50 - 9
60 - 2
70 - 7
80 - 2
90 - 4
100 - 2
110 - 12
120 - 2
130 - 2
140 - 3

@MakarovSoftware
Copy link
Author

Ok... very strange, on 1.0.7.3 it really works. I'll check this on a real project today and let you know how it goes

@MakarovSoftware
Copy link
Author

Ok, finally I got it :) Try out my last commit, but not sure that you'll think it's a bug :) The problem was that I've generated random names every time for same types - I mean different names for inner and outter fields. And everytime of course you can't find it in your cache dictionary, you save new record. If it's possible to fix - that'll be cool.

@StefH
Copy link
Collaborator

StefH commented Jun 8, 2017

I will check your project.

However you can also fork this project and make a pull request on my source code : MemoryLeakTest project in scr-console folder.

@MakarovSoftware
Copy link
Author

Ok, will do

@StefH
Copy link
Collaborator

StefH commented Jun 8, 2017

I did quickly check your test code.
But this is not a bug, because you are creating different anonymous types (based on a random name)

See this example:

var list = new [] { 1, 2, 3 };
var q = list.AsQueryable();
var resultA = q.Select(x => new { A = x });
var resultB = q.Select(x => new { B = x });

The code above creates 2 different types.

System.Linq.Dynamic.Core will do the same, except it's dynamic.

@MakarovSoftware
Copy link
Author

Yep, that's why I said that probably it's not a bug. But actually I can use same type in different parts of program, use different names and get this memory leak. And it's not a good idea. Maybe will be better to remove this string name from dictionary's key? Just leave only type names?

@StefH
Copy link
Collaborator

StefH commented Jun 9, 2017

This sounds possible, I will take a look at the code and do some tests.

@StefH StefH changed the title Memory leak in Join method [Question] Memory leak in Join method Jun 9, 2017
@StefH
Copy link
Collaborator

StefH commented Jun 9, 2017

Sorry, this is not possible. Because the dynamic generated types do not only define the Type for each property, but off course the property-name itself is also generated.

@StefH StefH closed this as completed Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants