Managed Heap Size Limit in C # Application

Can I configure the application in C # to limit memory consumption, say, 200 MB? IOW, I don't want to wait for an automatic GC (which seems to allow the heap to grow much more than is necessary for this application).

I know that in Java there is a command line switch that you can pass to the JVM that achieves this. Is there an equivalent in C #?

ps

I know that I can call GC from code, but this is something that I would prefer not to do periodically. I would prefer to install it once at startup and forget it.

+5
source share
3 answers

CLR. , , CLR.

, . , .

, , . , : .NET?

+4

, CLR . API- Windowsยฎ C CLR. , CLR ( , , , ). CLR , OutOfMemoryException . CLR .

: http://msdn.microsoft.com/en-us/magazine/cc163567.aspx#S2

:

, , , CLR .

, , .

+2

, SetProcessWorkingSetSizeEx, , , . , GC , OutOfMemoryExceptions.

+1

All Articles