Valhalla Legends Forums Archive | Java Programming | Java burning up CPU resources

AuthorMessageTime
TangoFour
What a surprise!

No really, what are common causes of Java demanding huge amounts of CPU time? The memory consumption of my bot is minimal, yet it takes on full CPU time (99%). Is there any way code-wise I could prevent this?
November 26, 2004, 4:39 PM
The-FooL
What are you doing to use that much?  I run a JavaOP and a JBLS Server in the background on my comp, both have minimal memory usage and CPU usage.  You probably have some sort of infinite loop going on that is using all the processor time.
November 26, 2004, 5:00 PM
TangoFour
My connection code uses an infinite loop to continuously check for incoming data - whereas the main code block has a continuous loop checking if there are completed packets ready to be handled.

Perhaps I should just download JavaOP and adapt it to suit my needs?
November 26, 2004, 5:25 PM
iago
It's fairly easy to write plugins for JavaOp.

But my recommendation is to use blocking i/o.  Make it stop and wait for data to arrive before it goes ahead and processes it.  That's how I do it.
November 26, 2004, 6:44 PM
TangoFour
Well, basicly I want a WarCraft 3 bot that automaticly determines what privileges should be granted to which accounts by quering my website. This should be checked at startup.

I also want to add a command such as:

[code]!iam TangoFour[/code]

After which the user can confirm if this account is indeed his on the website, so that that account should gain access appropriate to that user's rank the next time the bot reloads his user list.

Another thing I want to add is the ability to pass a Statstring to the website so it can calculate what awards a person should receive.

---

So basicly, I'd need to overhaul quite a bit of JavaOP I think
November 26, 2004, 6:50 PM
iago
That could probably be done using plugins.  You could create a custom event, for when somebody joins the channel to do the checking.  You can make a custom command, !iam.  You can do any of this stuff without touching my code.  The only thing might be assigning access based on this -- allthough I think you could make a call out to the modify user class (the same one my setuser command uses) to assign them flags.  The flags required for certain commands can be changed in the configuration files, without writing any code, if you don't like how my commands are set up.

If you need to go into more details on how you'd write a plugin to suit a particular purpose, you should either:
a) Use my official forum on http://ix86.cold-chaos.net/forum
b) Talk to me via IM (my info is on the left)

I think JavaOp could be adapted to suit your needs, though.
November 26, 2004, 10:23 PM

Search