Bug 30849 - Memory leak in AppDomain
Summary: Memory leak in AppDomain
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Alexander Kyte
URL:
Depends on:
Blocks:
 
Reported: 2015-06-05 11:36 UTC by smallwill
Modified: 2017-10-06 20:29 UTC (History)
5 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description smallwill 2015-06-05 11:36:18 UTC
$ mono --version
Mono JIT compiler version 4.0.1 (tarball Thu May 28 09:08:28 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen



The following simple code result in a memory leak (growing memory usage over time in task manager):

for (var i = 0; i < 10000; i++) 
{
var appDomain = AppDomain.CreateDomain(i.ToString());
AppDomain.Unload (appDomain);
GC.Collect ();
GC.WaitForPendingFinalizers ();
}
Comment 1 Alexander Kyte 2015-06-08 19:04:35 UTC
The master branch on mono didn't exhibit this space leak when I tried to reproduce.

~/mono/mono (appdomain_leak*) $ mono --version
Mono JIT compiler version 4.3.0 (appdomain_leak/8b466ec Mon Jun  8 18:20:28 EDT 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug
	LLVM:          supported, not enabled.
	GC:            sgen

http://i.imgur.com/FoKrIdO.png
Comment 2 Alexander Kyte 2015-06-09 17:20:14 UTC
Is this on linux or on OSX?
Comment 3 smallwill 2015-06-10 04:27:49 UTC
This is on lubunutu 14.04
Comment 4 Alexander Kyte 2015-06-11 18:03:06 UTC
It looks like we're leaking all of our generic method headers.
Comment 5 Alexander Kyte 2015-06-22 11:46:14 UTC
https://github.com/mono/mono/pull/1880
Comment 6 Zoltan Varga 2017-04-13 02:14:35 UTC
I can still repro this on osx with master -> REOPEN.
Comment 7 Zoltan Varga 2017-04-13 04:47:03 UTC
Fixed some newly added leaks in:
https://github.com/mono/mono/pull/4685