Link to home
Start Free TrialLog in
Avatar of gb874554
gb874554

asked on

VB limit itself to X CPU usage and ram usage

Hello,

i would like to know how to have a VB.net software to limit itself to X CPU usage and ram usage. How can this be done?

Thanks
Avatar of GMGenius
GMGenius
Flag of United Kingdom of Great Britain and Northern Ireland image

Open your project properties page, then select the compile tab
Click on Advanced Compile Options, you can select the Target CPU there
In .NET 2008 you can also choose the framework
I dont know how you can limit the RAM usage though
I am not sure why you want to do this, however, for CPU usage, have a look at Processor Affinity settings http://msdn.microsoft.com/en-us/library/system.diagnostics.process.processoraffinity%28v=VS.90%29.aspx

Am not sure if you can do this for RAM
You may want to look at http://blogs.msdn.com/b/oldnewthing/archive/2005/03/21/399688.aspx which discusses various insights into what you are attempting to do (though mainly discourages it... almost)
I have had to do this,
I had to set the Target CPU to x86 so when it was run on a 64 bit OS the underlying 32bit only DLL would work, without doing this the DLL failed to work
Avatar of andr_gin
andr_gin

Only setting a RAM usage maximum for an application will only prevent a crashing application from using all the RAM of the machine and the application will be terminated with an OutOfMemory exception. If you want to stay below a defined limit and keep your application running, the application itself has to handle things like caching of data in a way that it uses not more than a defined value and swap not frequentyl used data to a temporary file.
Avatar of gb874554

ASKER

What is the best way of setting a RAM usage maximum for an application? (in VB.net)
ASKER CERTIFIED SOLUTION
Avatar of GMGenius
GMGenius
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is right, it seams it can not be done. Thanks anway.