CPU Usage so high

This is a discussion on CPU Usage so high within the Windows Programming forums, part of the Platform Specific Boards category; I was wondering how I could lower the CPU Usage of my program, currently the program only has a layout ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    288

    CPU Usage so high

    I was wondering how I could lower the CPU Usage of my program, currently the program only has a layout and no actual working code but it uses my CPU at 60%.

    Is this normal? But i was trying this with other programs such as Windows media player and its CPU Usage was 2%.

    I have no timers or loops in my program just the butons and the form, and i have no idea why it uses my CPU so much.

  2. #2
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    60% !!

    What compiler?
    Can I see some of your code? I mean, my application I'm making is filled with wrappers for most of my controls and subclasses for heaps of controls and I get a max of 4% usage and that takes a lot of stuff to do that.

    What processor do you have? How much ram?

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    Compiler: MSVC++ 6
    Processor: 3 Ghz Pentium 4
    Memory: 1024 mb ram

    and the code was messy (i dont know how to add tabs to make my code look neat with code tags lol) to add on this so im going to attach it
    Attached Files Attached Files

  4. #4
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Nice system ... Well with specs like that it shouldn't make a hit when it's just idle.

    [edit:] Well there is nothing in your code that should make it go that high when you aren't actually doing anything with it.

    If however you are say, typing and clicking buttons and stuff 60% is not to hard to reach although even on my system (2.8Ghz) I only hit 38%, but then again my system is different because of my massive cooling.

    Is it very hot? Maybe you have a cooling problem, the closer to super conductivity the faster the system and less constant load.
    Last edited by Mithoric; 12-21-2003 at 12:23 AM.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    Well im sure its not cooling lol 4 fans usually at a constant 30 celcius or less but it maybe the fact that i use peekmessage instead of getmessage, i just read a post about how it uses more of the CPU and lol why would i click useless buttons its 60% in idle, im going to try and use WaitMessage() before PeekMessage and maybe itll workout

    Thanx for the help though, Mithoric

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    Well i fixed it and achieved 0% usage but it kinda sux, it paints slower and stuff, ill just switch to GetMessage i suppose, but the thing is I need the program to accept data from clients through winsock and I have NO idea how to implement it, so Im not really sure what to do

    Do you know how to implement a basic server to client program? into the code i already posted

  7. #7
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Sure, creating that is pretty simple. Here is a great winsock tutorial!

    http://www.hal-pc.org/~johnnie2/winsock.html

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    dude this site is perfect, has tutorial and the code, THANX MAN!! you saved my life like twice now lol keep it up!

    thanx again mithoric

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    just 1 question, does the code on his site support multiple clients to 1 server? I really dont know lol i just switched over from VB a couple of months ago and I've never used winsock until now so its all a bit blurry

  10. #10
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    Hmm.. I'm not quite sure about that, I'll have to investigate.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions on multiple thread programming
    By lehe in forum C Programming
    Replies: 11
    Last Post: 03-27-2009, 07:44 AM
  2. Net cpu usage of pthreads?!
    By mynickmynick in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2008, 07:59 AM
  3. Help with high CPU usage
    By 51dunk in forum C Programming
    Replies: 11
    Last Post: 07-23-2008, 02:25 AM
  4. Calculating CPU Usage
    By vitaliy in forum Linux Programming
    Replies: 3
    Last Post: 08-21-2005, 09:38 AM
  5. fseek high cpu usage?
    By chunlee in forum C Programming
    Replies: 2
    Last Post: 02-19-2005, 06:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21