I would like to know how to use SetProcessWorkingSetSize in C#
I understand that with this function I can restrict the memory usage of a process.
Any example code, please?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Lalit MPosted Dec 28, 2009, 1:22 PM
-> SetProcessWorkingSetSize Sets the minimum and maximum working set sizes for the specified process. System.Diagnostics.Process.MaxWorkingSetSystem.Diagnostics.Process.MinWorkingSet
Definition:-> [DllImport("kernel32.dll", SetLastError=true)] static extern int SetProcessWorkingSetSize ( int hProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize)
->Everseen memory usage of a program go down as soon as it's minimized. show this programmatically.
Call SetProcessWorkingSetSize or EmptyWorkingSet.
Also Show here SetProcessWorkingSetSize methods
Example -1
Example -2
Narcis ParfenePosted Dec 30, 2009, 8:45 AM
SetProcessWorkingSetSize( GetCurrentProcess(), -1, -1 );
I can clear memory.
But I want to RESTRICT memory for a process.
Supose that i have
Process.Start("array.exe");
That program ( array.exe ) uses up to 4MB memory, and I want to not allow to use more than 2MB.
When the program exceeds 2 MB, I want to stop the process.
Is that possible ? A code please, please, please?