How to control the memory and CPU usage

How to control the memory and CPU usage

Post by u8526.. » Wed, 15 Nov 2000 04:00:00



I want to create an enviroment on my computer by controlling the memory and cpu usage.For example,keep the cpu with 70% usage and memory 80% used.How do I do this by calling win32 API?I thought I can allocate memory to a variable until the usage up to what I want it to be but I also think maybe there's a better way,right?As for cpu usage,I really have no idea.Please give me some clues.Thanks.

Derek

 
 
 

How to control the memory and CPU usage

Post by Jackson Ye » Wed, 15 Nov 2000 04:00:00


Why do you want to do this?  If you're trying to run a stress test on your
computer, there are already plenty of programs out there capable of giving
you a through analysis of your system.

If you really want to go ahead and do this though, you can get the amount of
memory available using GlobalMemoryStatus() and then simply allocate a chunk
of memory of the size that you want.  As far as CPU usage is concerned, you
can just run a repeated loop with a small pause in between and constantly
monitor the CPU usage using the performance objects to increase or decrease
the length of the pause.  This is likely to be very imprecise though, since
you'll be constantly adjusting for all of the other programs which are
running on the system at the same time.

HTH,
Jackson Yee
http://jacksonyee.welcome.to/
E-mails for help will be ignored unless I had asked for them.  Please post
to the group.


Quote:> I want to create an enviroment on my computer by controlling the memory

and cpu usage.For example,keep the cpu with 70% usage and memory 80%
used.How do I do this by calling win32 API?I thought I can allocate memory
to a variable until the usage up to what I want it to be but I also think
maybe there's a better way,right?As for cpu usage,I really have no
idea.Please give me some clues.Thanks.
Quote:

> Derek