Bug 37486 - Memory Leak With NLog Async Logging
Summary: Memory Leak With NLog Async Logging
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: 4.2.0 (C6)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-01-07 18:24 UTC by Edgar González
Modified: 2017-10-11 17:44 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Edgar González 2016-01-07 18:24:29 UTC
We found that when we updated to the latest Mono Version (4.2) our services began to show an increase in memory usage, after some profiling and testing and some research we found out it was the Logging section the one to be blamed, this section uses NLog async writting to save different purpose logs. We removed the async part and the problem was fixed. You can find more details here https://github.com/eleonel1/Mono4.2NLogMemoryLeak
Comment 1 Vlad Brezae 2016-11-08 22:35:37 UTC
Hello Edgar,

     Can you offer some information on how to repro the leak ?

Thanks, Vlad
Comment 3 Vlad Brezae 2017-01-03 20:57:49 UTC
I have tried reproducing the leak to no avail on different platforms using installed 4.6 mono. I ran the program, did a request from the browser on the service and then just let the application run indefinitely. In both cases the managed memory slowly grows but it is all collected when a major collection happens.

@Edgar Have you been running with a custom compiled mono, since it looks like it from the --version output ?

As a side note, I did notice increased cpu consumption after a few seconds, going all the way to 99%, while on linux and mac the cpu remains idle. @Niklas could somebody from the windows team investigate if this cpu consumption still happens and why ?
Comment 4 Edgar González 2017-01-03 22:31:54 UTC
no custom compiled version, just what apt-get installs by default.
Comment 5 Vlad Brezae 2017-01-06 18:12:29 UTC
Left the test case running for a few days, on linux this time (after accessing the MemoryLeakTest service from the browser) and no leak was observed. Couldn't repro even with 4.2.

If different steps need to be taken to observe the leak let me know, and if you can observe it it would be useful to get the output by passing in the environment MONO_LOG_LEVEL=debug and MONO_LOG_MASK=gc. At this point, not much can be done.
Comment 6 Rodrigo Kumpera 2017-10-11 17:44:34 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!