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

Memory leak issue #306

Closed
lijunle opened this issue Sep 5, 2019 · 9 comments · Fixed by #307
Closed

Memory leak issue #306

lijunle opened this issue Sep 5, 2019 · 9 comments · Fixed by #307
Assignees
Labels
bug Something's wrong.

Comments

@lijunle
Copy link

lijunle commented Sep 5, 2019

Describe the bug

It is hard to describe or repro the bug. I rerun this Trello in an Azure function every 5 minutes. From the telemetry, it spend longer and longer time to send the requests. My guess is, there is some memory leak issue in the code. Do you have any ideas?

Screenshots

Vertical axis is the time to send the request.

image

Desktop (please complete the following information):

  • OS: Linux
  • .Net Target: .Net core 2.2
  • Version [e.g. 22]

Additional context

I tried to call TrelloConfiguration.Cache.Clear() after each call but it does not help.

@gregsdennis
Copy link
Collaborator

Thanks for reporting this. Do you modify TrelloConfiguration at all, or are you using the default settings.

Also, can you let me know what package version you're using, please?

@gregsdennis gregsdennis self-assigned this Sep 5, 2019
@gregsdennis gregsdennis added the bug Something's wrong. label Sep 5, 2019
@lijunle
Copy link
Author

lijunle commented Sep 5, 2019

No modification on TrelloConfiguration class.

Version 3.8.1.

@lijunle
Copy link
Author

lijunle commented Sep 5, 2019

The source code is here: https://gist.github.com/lijunle/eafa8cb87f651b2dd904c8352ed5e6c6

It is quite short.

@gregsdennis
Copy link
Collaborator

Thanks. I'll have a look tonight.

@gregsdennis
Copy link
Collaborator

So it looks like there may be a memory leak, but I don't think that's the primary issue. The EventAggregator holds on to everything that subscribes using weak references until it discovers (through an event publish) that it doesn't exist.

However, with each subscriber, it must check to see if that object hasn't already subscribed, and just about every object subscribes. As the number of subscribers increases, this check takes more and more time. This is the source of the increasing delay.

I'll be publishing v3.10.1 soon, which completely disables the EventAggregator when consistency processing is disabled (which appears to be your case).

@lijunle
Copy link
Author

lijunle commented Sep 9, 2019

@gdziadkiewicz From monitor, the issue is resolved! Thanks a lot for the quick help!

@lijunle
Copy link
Author

lijunle commented Sep 10, 2019

Hmm... The request time is stable, however, there is still some kinds of memory leak.

image

@lijunle
Copy link
Author

lijunle commented Sep 19, 2019

image

It shows the BoardContext is never released. I took a quick look at the code. This line of code is strange. The Synchronized handler is never released.

https://github.com/gregsdennis/Manatee.Trello/blob/1b40470dfb1c9b6abe79b740a2a601cec37d885f/Manatee.Trello/Board.cs#L379

This seems a general issue on all context classes.

https://github.com/gregsdennis/Manatee.Trello/blob/ad33fa0a6bac4ad9fc629634ca39fdd3175bf3c7/Manatee.Trello/Card.cs#L429

@lijunle
Copy link
Author

lijunle commented Sep 19, 2019

@gregsdennis Why the Synchronized is declared as an event? It sounds should be a weak reference callback on the constructor.

https://github.com/gregsdennis/Manatee.Trello/blob/cce81cbab2688f4f7a1a2a6a47f5b408d81f4f75/Manatee.Trello/Internal/Synchronization/SynchronizationContext.cs#L26

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

Successfully merging a pull request may close this issue.

2 participants