简体   繁体   English

没有记录Mono GC的最大堆大小。 在生产中使用安全吗?

[英]Mono GC max-heap-size isn't documented. Is it safe to use in production?

I need to set an upper bound to the memory used by Mono. 我需要为Mono使用的内存设置一个上限。

According to blogs it's possible to use the parameter max-heap-size to cap the memory usage. 根据博客的说法,可以使用参数max-heap-size来限制内存使用量。 According to experimentations, and according to the code , it indeed does what I want. 根据实验和代码 ,它确实可以实现我想要的功能。

However, this option isn't documented . 但是, 未记录此选项。

Therefore: is it safe to rely on this option in production (or does it have drawbacks I don't see, like eg: no guarantee to still be available in future version of Mono)? 因此:在生产中依靠此选项是否安全(或者它具有我看不见的缺点,例如:无法保证在将来的Mono版本中仍然可用)?

It is documented, and here's one way to get the documentation: export an invalid MONO_GC_PARAMS , start mono : 已记录了文档,这是获取文档的一种方法: export无效的MONO_GC_PARAMS ,启动mono

export MONO_GC_PARAMS=xxx
mono sample.exe

and get the help: 并获得帮助:

Warning: In environment variable `MONO_GC_PARAMS': Unknown option `xxx`. - Ignoring.

MONO_GC_PARAMS must be a comma-delimited list of one or more of the following:
  max-heap-size=N (where N is an integer, possibly with a k, m or a g suffix)
  soft-heap-limit=n (where N is an integer, possibly with a k, m or a g suffix)
  nursery-size=N (where N is an integer, possibly with a k, m or a g suffix)
  major=COLLECTOR (where COLLECTOR is `marksweep', `marksweep-conc', `marksweep-par', 'marksweep-fixed' or 'marksweep-fixed-par')
  minor=COLLECTOR (where COLLECTOR is `simple' or `split')
  wbarrier=WBARRIER (where WBARRIER is `remset' or `cardtable')
  stack-mark=MARK-METHOD (where MARK-METHOD is 'precise' or 'conservative')
  [no-]cementing
  evacuation-threshold=P (where P is a percentage, an integer in 0-100)
  (no-)lazy-sweep
 Experimental options:
  save-target-ratio=R (where R must be between 0.10 - 2.00).
  default-allowance-ratio=R (where R must be between 1.00 - 10.00).

As you can see max-heap-size is listed, and not in the Experimental Options . 如您所见,列出了max-heap-size ,而不是在Experimental Options So I'd say it's safe. 所以我说这很安全。

It is documented in the mono man page : 它记录在mono手册页中

Sets the maximum size of the heap. 设置堆的最大大小。 The size is specified in bytes and must be a power of two. 该大小以字节为单位指定,并且必须为2的幂。 The suffixes k', m' and `g' can be used to specify kilo-, mega- and gigabytes, respectively. 后缀“ k', m”和“ g”可分别用于指定千字节,兆字节和千兆字节。 The limit is the sum of the nursery, major heap and large object heap. 限制是托儿所,主要堆和大对象堆的总和。 Once the limit is reached the application will receive OutOfMemoryExceptions when trying to allocate. 一旦达到限制,应用程序将在尝试分配时收到OutOfMemoryExceptions。 Not the full extent of memory set in max-heap-size could be available to satisfy a single allocation due to internal fragmentation. 由于内部碎片,不能以max-heap-size设置全部内存范围来满足单个分配。 By default heap limits is disabled and the GC will try to use all available memory. 默认情况下,禁用堆限制,并且GC将尝试使用所有可用内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM