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
VEEPROGAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.