我可以(而且我曾经想)设置在.net中的最大堆大小?大堆、大小、我曾经、net

2023-09-02 01:40:12 作者:别留我独自一人

我来自一个Java背景,我习惯说的是什么JVM的最大堆大小应该的事情之一。如果正在运行的程序试图吞下多是允许的,而垃圾收集器无法释放更多的资源,那么OutOfMemoryError异常被抛出,这一切都一声巨响。因此,设置最大堆大小是很重要的Java语言。

Coming from a java background, one of the things I am used to is telling the JVM what the maximum heap size should be. If the running program tries to swallow more than is allowed, and the garbage collector cannot free any more resources, then OutOfMemoryError is thrown and it all goes bang. So setting the maximum heap size is important in Java.

这是否适用于.NET?你能设置堆大小限制?是否CLR只是不停,直到达到机器的物理极限扩大其堆?或者是不是在.net中的一些微妙的原因,一个问题,我的Java眼罩看见?

Does this apply in .net? Can you set the heap size limits? Does the CLR just keep growing its heap until it reaches the machine's physical limits? Or is it not an issue in .net for some subtle reason that my Java blinkers stop me from seeing?

推荐答案

您不能设置最大堆大小的.NET。

You can't set max heap size in .Net unless you host the CLR yourself in a process.

编辑: 为了控制CLR的内存分配,包括最大堆大小,您需要使用托管API主办的CLR和专门使用的内存管理接口,一些起动信息可以在这里找到的