Sign in to follow this  
Maxjen

Program using too many resources

Recommended Posts

Maxjen    199
Hi,

I have a little problem with my program. It's a simple opengl application but it uses too many resources. Whenever I start it my processor fan gets very loud after a few seconds and I don't understand why. I think the problem is connected to my main loop. It is an indefinite while loop so it makes sense to me that my computer should be working at all times. However there must be something that other games do differently, because I don't hear my processor fan while playing them. Can someone tell me what that might be?

My best guess is that I'm doing too much during each execution of the while loop. I have a list of objects which are simulated by box2d and update their position and rotation at every iteration of the loop. Should I rather update them only after certain timesteps? But if this is true I still don't understand why because then each iteration would finish faster but there would also be more iteration so my computer should still be working all the time and thus use the same amount of resources, right? I hope someone can explain this to me.

Share this post


Link to post
Share on other sites
Waterlimon    4398
Note that there might be better ways to do this.

But try putting a Sleep(millisecondshere); in the loop. It stops executing the program for a small time, so if theres nothing to compute you can make it sleep for a while. You probably need to include windows.h or some other header.

Also are you sure its the processor fan and not the GPU fan?

You would probably use it by timing your loop iteration, and if theres still time until the start of the next time step, sleep for a while.

Share this post


Link to post
Share on other sites
Antheus    2409
[quote]Whenever I start it my processor fan gets very loud after a few seconds and I don't understand why.[/quote]

Poor hardware build. The fan is borderline for the CPU/GPU, so even slightest load increase causes a ramp up. Add to that airflow that isn't optimized for noise, possibly cheap(er) bearings, perhaps slightly-off thermal diode.


A noise-aware hardware configuration should be inaudible even when running at 100% load on everything, CPU/GPU/RAM/Northbridge/DVD/USB/TLA/ETC....

Noise is often not a factor or at least it's assumed that user will never go over a few percent.

Many laptops are not even remotely built for >25% load, so a dual core machine that runs Flash on single core will peg the fans.

And yes, many Macs fail on all of the above.

Share this post


Link to post
Share on other sites
Maxjen    199
Thanks for the replies.

[quote name='Waterlimon' timestamp='1333812700' post='4929052']
But try putting a Sleep(millisecondshere); in the loop. It stops executing the program for a small time, so if theres nothing to compute you can make it sleep for a while. You probably need to include windows.h or some other header.
...
You would probably use it by timing your loop iteration, and if theres still time until the start of the next time step, sleep for a while.
[/quote]
Is this the same thing as capping the framerate? I might actually do that. In fact I just found out that the game I was comparing it with (braid) also caps the framerate at 30. I'll try to find out how to do this sleep thing on linux.

I'm still wondering though if there is anything else I might be doing wrong? Because I feel that even games like ut2004 where I have over 100 frames per second don't create as much noise as mine.(although that's maybe operating system related as that was on windows or my feeling is deceiving me)

[quote name='Waterlimon' timestamp='1333812700' post='4929052']
Also are you sure its the processor fan and not the GPU fan?
[/quote]
It might be the GPU fan, I have no idea.

Antheus:
It is true that I have a poor hardware build. My laptop is noisy with every game I play. I was just wondering because with my program it is especially noisy.

Share this post


Link to post
Share on other sites
iMalc    2466
Your program will have what is known as a "[url="http://en.wikipedia.org/wiki/Busy_waiting"]busy loop[/url]".
Hey, next time you're playing UT2004, drop in on the "Disasterous Consequences" server. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this