Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

CPU Usage

Hi

My application runs with 100% CPU usage!!!!

I have no iterative calculations.
I do however use dll and write to xml files (using clientdatasets).

Anything I should watch out for?

Tx
0
VEEPROG
Asked:
VEEPROG
1 Solution
 
BobcsiCommented:
Try to insert Application.Processmessages; to your code.

Bobcsi
0
 
EvarestCommented:
Or when you have a Thread running with some kind of internal loop, insert sleep(10) to trim down the cpu usage...

Evarest
0
 
Wim ten BrinkSelf-employed developerCommented:
Use of Sleep(0) is as effective as Sleep(10) since both commands will pass processor time to another thread...

There could be code in the DLL that needs this much processor time.
It could also be that your XML file is quite huge, thus Windows has to do some memory swapping and other stuff to write it all to file.

One thing you could try is to increase or decrease the thread and process priority of your application. If you increase it, it will run faster and this it will finish faster too. But it might starve some other processes and threads of their processing time. If you lower it, your application will slow down but it might also take less processor time that way.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DavidBirch2dotComCommented:
You could also try giving you program a lower importance

SetPriorityClass( GetCurrentProcess,HIGH_PRIORITY_CLASS);

this question shows how to do it

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20956360.html

David
0
 
HypoviaxCommented:
Watch out for the deadly infinite loops. Any loops that are not cancelling (ending) will quickly chew up usage. 100% CPU usage is a sure sign of some loop calculation that cannot end properly. Check the terminating conditions to be sure loops can terminate eventually.

Regards,

Hypoviax
0
 
Wim ten BrinkSelf-employed developerCommented:
The problem could be related to the ClientDatafiles and the generation of those XML files. Especially if you have a huge amount of data. This is because the ClientDataset will try and load it all, start swapping memory if RAM runs out which could happen quite fast and then it might have to process it's data to write it back to file again. Especially if data is converted from XML to binary and back again, you could eat up lots of CPU cycles. Which is why it might help to alter the priority of the thread or process. A higher priority will make it eat more CPU, but it will finish faster. A lower priority will slow it down but less CPU will be eaten. It depends on the actual situation.
0
 
moduloCommented:
PAQed with no points refunded (of 300)

modulo
Community Support Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now