C#内存分配

Bet*_*moo 3 c# allocation new-operator operator-keyword

  • 在c#中使用operator new可能会失败(例如,如果需要大内存)吗?-解决了-
  • 以及如何发现它?-解决了-
  • 新操作员可能会抛出哪些其他故障?

谢谢

Bri*_*sen 9

如果new失败,它将抛出OutOfMemoryException.此外,构造函数本身可能会抛出任何异常,具体取决于实现.

从OutOfMemoryException的MSDN文档:

以下Microsoft中间(MSIL)指令抛出OutOfMemoryException:

  • newarr

  • newobj