Skip to content

Commit 588e604

Browse files
authored
Update return values for GC.GetGeneration (#8993)
1 parent 87cf96f commit 588e604

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

xml/System/GC.xml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,22 +1083,24 @@ This method is most useful in monitoring scenarios for measuring the difference
10831083
<Docs>
10841084
<param name="obj">The object that generation information is retrieved for.</param>
10851085
<summary>Returns the current generation number of the specified object.</summary>
1086-
<returns>The current generation number of <paramref name="obj" />.</returns>
1086+
<returns>The current generation number of <paramref name="obj" />, or <see cref="F:System.Int32.MaxValue">Int32.MaxValue</see>.</returns>
10871087
<remarks>
10881088
<format type="text/markdown"><![CDATA[
10891089
10901090
## Remarks
1091-
Use this method to determine the age of an object, and then use that information with the <xref:System.GC.Collect%2A> method to force the garbage collector to collect objects in the same generation. For example, use this method when you have a set of objects that are created as a group and that become inaccessible at the same time.
10921091
1092+
Use this method to determine the age of an object, and then use that information with the <xref:System.GC.Collect%2A> method to force the garbage collector to collect objects in the same generation. For example, use this method when you have a set of objects that are created as a group and that become inaccessible at the same time.
10931093
1094+
Starting in .NET 8, this method might return <xref:System.Int32.MaxValue> for objects allocated on non-GC heaps. For more information, see [GC.GetGeneration might return Int32.MaxValue](/dotnet/core/compatibility/core-libraries/8.0/getgeneration-return-value).
10941095
10951096
## Examples
1096-
The following example demonstrates how to use the <xref:System.GC.GetGeneration%2A> method to determine the age of an object. The example then performs garbage collections to clean up memory and compare the pre and post collection memory totals in the console.
10971097
1098-
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp" id="Snippet1":::
1099-
:::code language="csharp" source="~/snippets/csharp/System/GC/Overview/class1.cs" id="Snippet1":::
1100-
:::code language="fsharp" source="~/snippets/fsharp/System/GC/Overview/class1.fs" id="Snippet1":::
1101-
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.gc.collect int example/VB/class1.vb" id="Snippet1":::
1098+
The following example demonstrates how to use the <xref:System.GC.GetGeneration%2A> method to determine the age of an object. The example then performs garbage collections to clean up memory and compare the pre and post collection memory totals in the console.
1099+
1100+
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp" id="Snippet1":::
1101+
:::code language="csharp" source="~/snippets/csharp/System/GC/Overview/class1.cs" id="Snippet1":::
1102+
:::code language="fsharp" source="~/snippets/fsharp/System/GC/Overview/class1.fs" id="Snippet1":::
1103+
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.gc.collect int example/VB/class1.vb" id="Snippet1":::
11021104
11031105
]]></format>
11041106
</remarks>
@@ -1150,17 +1152,22 @@ This method is most useful in monitoring scenarios for measuring the difference
11501152
<Docs>
11511153
<param name="wo">A <see cref="T:System.WeakReference" /> that refers to the target object whose generation number is to be determined.</param>
11521154
<summary>Returns the current generation number of the target of a specified weak reference.</summary>
1153-
<returns>The current generation number of the target of <paramref name="wo" />.</returns>
1155+
<returns>The current generation number of the target of <paramref name="wo" />, or <see cref="P:System.Int32.MaxValue" />.</returns>
11541156
<remarks>
11551157
<format type="text/markdown"><![CDATA[
11561158
1159+
## Remarks
1160+
1161+
Starting in .NET 8, this method might return <xref:System.Int32.MaxValue> for objects allocated on non-GC heaps. For more information, see [GC.GetGeneration might return Int32.MaxValue](/dotnet/core/compatibility/core-libraries/8.0/getgeneration-return-value).
1162+
11571163
## Examples
1158-
The following example demonstrates the use of the <xref:System.GC.GetGeneration%2A> method to determine the age of a weak reference object.
11591164
1160-
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/CPP/systemgcgetgenerationweak.cpp" id="Snippet1":::
1161-
:::code language="csharp" source="~/snippets/csharp/System/GC/GetGeneration/systemgcgetgenerationweak.cs" id="Snippet1":::
1162-
:::code language="fsharp" source="~/snippets/fsharp/System/GC/GetGeneration/systemgcgetgenerationweak.fs" id="Snippet1":::
1163-
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/VB/systemgcgetgenerationweak.vb" id="Snippet1":::
1165+
The following example demonstrates the use of the <xref:System.GC.GetGeneration%2A> method to determine the age of a weak reference object.
1166+
1167+
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/CPP/systemgcgetgenerationweak.cpp" id="Snippet1":::
1168+
:::code language="csharp" source="~/snippets/csharp/System/GC/GetGeneration/systemgcgetgenerationweak.cs" id="Snippet1":::
1169+
:::code language="fsharp" source="~/snippets/fsharp/System/GC/GetGeneration/systemgcgetgenerationweak.fs" id="Snippet1":::
1170+
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/VB/systemgcgetgenerationweak.vb" id="Snippet1":::
11641171
11651172
]]></format>
11661173
</remarks>

0 commit comments

Comments
 (0)