move FrameworkName from corlib to System
[mcs.git] / class / corlib / System / GC.cs
blob06a39a46d30ad0b40638d143a6fc70c2d0c61189
1 //
2 // System.GC.cs
3 //
4 // Author:
5 // Paolo Molaro (lupus@ximian.com)
6 //
7 // (C) 2001 Ximian, Inc. http://www.ximian.com
8 //
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Runtime.CompilerServices;
34 using System.Runtime.ConstrainedExecution;
35 using System.Security.Permissions;
37 namespace System
39 public static class GC
42 public extern static int MaxGeneration {
43 [MethodImplAttribute(MethodImplOptions.InternalCall)]
44 get;
47 [MethodImplAttribute (MethodImplOptions.InternalCall)]
48 extern static void InternalCollect (int generation);
50 public static void Collect () {
51 InternalCollect (MaxGeneration);
54 public static void Collect (int generation) {
55 if (generation < 0)
56 throw new ArgumentOutOfRangeException ("generation");
57 InternalCollect (generation);
60 [MonoDocumentationNote ("mode parameter ignored")]
61 public static void Collect (int generation, GCCollectionMode mode) {
62 Collect (generation);
65 [MethodImplAttribute (MethodImplOptions.InternalCall)]
66 public extern static int GetGeneration (object obj);
68 public static int GetGeneration (WeakReference wo) {
69 object obj = wo.Target;
70 if (obj == null)
71 throw new ArgumentException ();
72 return GetGeneration (obj);
75 [MethodImplAttribute (MethodImplOptions.InternalCall)]
76 public extern static long GetTotalMemory (bool forceFullCollection);
78 /* this icall has weird semantics check the docs... */
79 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
80 [MethodImplAttribute (MethodImplOptions.InternalCall)]
81 public extern static void KeepAlive (object obj);
83 [MethodImplAttribute (MethodImplOptions.InternalCall)]
84 public extern static void ReRegisterForFinalize (object obj);
86 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
87 [MethodImplAttribute (MethodImplOptions.InternalCall)]
88 public extern static void SuppressFinalize (object obj);
90 [MethodImplAttribute (MethodImplOptions.InternalCall)]
91 public extern static void WaitForPendingFinalizers ();
93 [ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
94 [MethodImplAttribute (MethodImplOptions.InternalCall)]
95 public extern static int CollectionCount (int generation);
97 [MethodImplAttribute (MethodImplOptions.InternalCall)]
98 private extern static void RecordPressure (long bytesAllocated);
100 public static void AddMemoryPressure (long bytesAllocated) {
101 RecordPressure (bytesAllocated);
104 public static void RemoveMemoryPressure (long bytesAllocated) {
105 RecordPressure (-bytesAllocated);
108 #if NET_4_0
109 [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
110 [MonoTODO]
111 public static GCNotificationStatus WaitForFullGCApproach () {
112 throw new NotImplementedException ();
115 [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
116 [MonoTODO]
117 public static GCNotificationStatus WaitForFullGCApproach (int millisecondsTimeout) {
118 throw new NotImplementedException ();
121 [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
122 [MonoTODO]
123 public static GCNotificationStatus WaitForFullGCComplete () {
124 throw new NotImplementedException ();
127 [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
128 [MonoTODO]
129 public static GCNotificationStatus WaitForFullGCComplete (int millisecondsTimeout) {
130 throw new NotImplementedException ();
133 [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
134 public static void RegisterForFullGCNotification (int maxGenerationThreshold, int largeObjectHeapThreshold) {
135 if (maxGenerationThreshold < 1 || maxGenerationThreshold > 99)
136 throw new ArgumentOutOfRangeException ("maxGenerationThreshold", maxGenerationThreshold, "maxGenerationThreshold must be between 1 and 99 inclusive");
137 if (largeObjectHeapThreshold < 1 || largeObjectHeapThreshold > 99)
138 throw new ArgumentOutOfRangeException ("largeObjectHeapThreshold", largeObjectHeapThreshold, "largeObjectHeapThreshold must be between 1 and 99 inclusive");
139 throw new NotImplementedException ();
142 [PermissionSetAttribute (SecurityAction.LinkDemand, Name = "FullTrust")]
143 public static void CancelFullGCNotification () {
144 throw new NotImplementedException ();
146 #endif