Preventing OutOfMemoryException with GC.AddMemoryPressure()?

前端 未结 2 1618
你的背包
你的背包 2020-12-15 07:05

I\'m currently debugging a method we use to tag images with a certain text before displaying them in our system.

The tag method looks like this at the moment:

<
2条回答
  •  醉梦人生
    2020-12-15 07:30

    If you are looking for a way to ensure you'll have enough memory available for an operation, use MemoryFailPoint.

    With this, through a using, you can define a region in which you will need a certain amount of memory. If that isn't available, it will throw a recoverable InsufficientMemoryException.

    See http://msdn.microsoft.com/en-us/library/system.runtime.memoryfailpoint.aspx for more information.

提交回复
热议问题