You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System/OutOfMemoryException.xml
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,7 @@ An <xref:System.OutOfMemoryException> exception has two major causes:
80
80
This type of <xref:System.OutOfMemoryException> exception represents a catastrophic failure. If you choose to handle the exception, you should include a `catch` block that calls the <xref:System.Environment.FailFast%2A?displayProperty=nameWithType> method to terminate your app and add an entry to the system event log, as the following example does.
Some of the conditions under which the exception is thrown and the actions you can take to eliminate it include the following:
@@ -89,6 +90,7 @@ An <xref:System.OutOfMemoryException> exception has two major causes:
89
90
You are attempting to increase the length of a <xref:System.Text.StringBuilder> object beyond the size specified by its <xref:System.Text.StringBuilder.MaxCapacity%2A?displayProperty=nameWithType> property. The following example illustrates the <xref:System.OutOfMemoryException> exception thrown by a call to the <xref:System.Text.StringBuilder.Insert%28System.Int32%2CSystem.String%2CSystem.Int32%29?displayProperty=nameWithType> method when the example tries to insert a string that would cause the object's <xref:System.Text.StringBuilder.Length%2A> property to exceed its maximum capacity.
You can do either of the following to address the error:
@@ -128,11 +130,13 @@ To prevent the <xref:System.OutOfMemoryException> exceptions, you must modify yo
128
130
The following example gets a array that consists of 200 million floating-point values and then calculates their mean. The output from the example shows that, because the example stores the entire array in memory before it calculates the mean, an <xref:System.OutOfMemoryException> is thrown.
The following example eliminates the <xref:System.OutOfMemoryException> exception by processing the incoming data without storing the entire data set in memory, serializing the data to a file if necessary to permit further processing (these lines are commented out in the example, since in this case they produce a file whose size is greater than 1GB), and returning the calculated mean and the number of cases to the calling routine.
0 commit comments