Bug 53145 - Max heap size is ignored or undocumented
Summary: Max heap size is ignored or undocumented
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-03-08 09:44 UTC by Tomasz Sętkowski
Modified: 2017-10-11 17:52 UTC (History)
4 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 Tomasz Sętkowski 2017-03-08 09:44:28 UTC
I have been trying to limit memory use for simple application compiled on mono (tried on 4.6 and 4.8). By examining profiler reports and VmSize in /proc/<pid>/status it seems that process is always exceeding my set maximum. I also run this application in docker with cgroup memory constraints and this application always gets killed by OOM. Even when I set max-heap-size=64m and docker constraints to 300M, then it still gets killed.
I tried to debug what is wrong with commands such as:

MONO_GC_DEBUG=1 MONO_GC_PARAMS="max-heap-size=60m,soft-heap-limit=30m,nursery-size=4m" mono --gc=sgen --profile=log:heapshot,output=app.heapshot.mlpd --debug app.exe

Then with mprof-report I get following

	Mono System:
		User Time                      : 376000000
		System Time                    : 286600000
		Total Time                     : 752000000
		Working Set                    : 135434240
		Private Bytes                  : 2249687040
		Virtual Bytes                  : 2328453120
		Page Faults                    : 170790
		CPU Load Average - 1min        : 4.950000
		CPU Load Average - 5min        : 2.930000
		CPU Load Average - 15min       : 2.150000
GC summary
        GC resizes: 0
        Max heap size: 0
        Object moves: 0
        Gen0 collections: 288, max time: 124699us, total time: 4629444us, average: 16074us
        Gen1 collections: 9, max time: 127756us, total time: 524645us, average: 58293us
        GC handles weak: created: 36, destroyed: 36, max: 32
        GC handles weaktrack: created: 58059, destroyed: 57997, max: 14183
        GC handles normal: created: 3, destroyed: 1, max: 3

What does not seem right in above is - GC resizes: 0, Max heap size: 0, Virtual Bytes, Private Bytes

I used this man pages source as reference https://github.com/mono/mono/blob/master/man/mono.1#L1191
I am installing mono from debian repository http://download.mono-project.com/repo/debian/
Comment 1 Vlad Brezae 2017-03-13 15:31:38 UTC

    Could you try running with MONO_LOG_LEVEL=info MONO_LOG_MASK=gc and post the output  (it should give heap sizes after each collection). Doing another run passing --stats to mono will output additional info regarding memory used by gc.
Comment 2 Rodrigo Kumpera 2017-10-11 17:52:05 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!