|
You last visited: Today at 01:32
Advertisement
[Help]Ram Usage
Discussion on [Help]Ram Usage within the CO2 Private Server forum part of the Conquer Online 2 category.
09/26/2010, 23:25
|
#1
|
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
|
[Help]Ram Usage
Hey guys...I don't know if anything like this have happened to you too but the source is eating up RAM slowly...I was wondering if all of this happens because of the timers (that repeat every .1 second) if so ... I have a lot of "if's" in them checking the servertime...would it reduce the ram usage by using a switch (Servertime.hr/day/blahblah) and make with cases?
if this is not the problem of the ram usage can anybody tell me what causes this ram usage?
EDIT: i'm talking about tanel's 5165 ini source
|
|
|
09/27/2010, 02:46
|
#2
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
Sounds like a memory leak if you are consistently using more an more ram as the server is online.
This can be caused by all sorts of things but mostly make sure you are disposing of things when done (if applicable. EG: socket connections, mysql connections, reader/writers)
If you have a thread for various server functions make sure you are repeating it properly
Eg: if you have a thread that runs a function (lets call it Run()) and at the end you are calling the function again every time, you tend to cause memory leaks vs a while statement or something better.
If statements vs switches is more an efficiency issue afaik.
Timers are.... to be avoided in many case (what the **** are you using .1 second timers for? use a *** **** thread lol)
|
|
|
09/27/2010, 07:31
|
#3
|
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
|
well yes it's a thread...actually idk what's the difference... but the thread runs every .1 second i believe...
and what about "afaik" ... you mean that you don't know?
somebody told me that using switches is a more effective way than by using those "if's" but idk if it's like that...
|
|
|
09/27/2010, 08:09
|
#4
|
elite*gold: 0
Join Date: Nov 2006
Posts: 805
Received Thanks: 464
|
Quote:
Originally Posted by ryuchetval
well yes it's a thread...actually idk what's the difference... but the thread runs every .1 second i believe...
and what about "afaik" ... you mean that you don't know?
somebody told me that using switches is a more effective way than by using those "if's" but idk if it's like that...
|
Okay first, what is this thread doing? Depending on the situation it's better to use a switch (sounds like in this case it might be just because of the frequency it's running the function).
afaik = As far as I know.
Everyone says this is more efficient than that blah blah... depends what it is.
Like, a do while block is great to use for certain things like...
while (botting)
{
if (this)
doThis();
else
botting = false;
}
just have to make sure you turn it off when you don't need it.
if/ else statements... those are about as basic as it gets tbh,
only use them if (needed)  )
|
|
|
09/27/2010, 08:29
|
#5
|
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
|
the thread is to do several things in the world...like cheking broadcasts, items on ground, and then check the server times for several things like : vote reset points, gw start/end, dis city start/end...all of these are using a lot of "if" statements....so if it's better to use a switch or more tell me
|
|
|
09/27/2010, 08:34
|
#6
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
Sounds like you should be splitting this into multiple threads...
Personally I prefer to split things by how often they are called. Eg: a slow thread that runs once per second for things that are less common and something that runs every 100 ms for more often things.
Hell even a 3rd thread that runs every minute may be appropriate for things like events.
Think about it... if you are using a thread that runs every 100 ms, you don't wanna be checking every single time to see if an event needs to start (That may only start once a day lol)
|
|
|
09/27/2010, 08:38
|
#7
|
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
|
yea it's true that it doesn't need to check every .1 second for this
thanks for your opinion i'll do it
|
|
|
09/27/2010, 13:55
|
#8
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
For a fairly 'finished' server when it comes to feature I'd do something like 2 server threads and 2 client threads (MANY will disagree with me as there are some knowledgeable people who stress the importance of minimizing thread usage but this seems like a reasonable amount to me.)
Fast server thread: Once per 500 ms or so (mob movement/attacks, removing ground items)
Slow server thread: Once per minute: Control events, server states, etc)
Fast client thread: Once per 100 ms or so (removal of client effects, check if attacks need to be happening, other 'often' stuff)
Slow client thread: once per second or so. Adding clients stamina, xp, decreasing pk points. etc... things that don't need to be checked super fast but still happen fairly often.
If you structure your server correctly this + your main thread should be all you ever really need. Maybe a packet queue thread for handling sending of packets but I don't see that being TOO much of an issue.
If you aren't creating threads left right and center (Eg: Thread per client, thread per event, etcetc that I've seen done all over) and you are using your resources correctly (removing from dictionary when not needed. Eg: Players, mobs, items, etc) and are not doing bad loops timers or anything like that then your ram usage shouldn't be all that high. Just as you code things always check the ram to ensure you aren't developing memory leaks. If you do, look at your code and try to revise it so that you fix the problem before it becomes a true issue.
|
|
|
09/27/2010, 14:19
|
#9
|
elite*gold: 0
Join Date: Nov 2009
Posts: 390
Received Thanks: 321
|
Thread usage should not be as low as you're proposing; IMO a good server should make good use of resources available (eg. threads, memory etc.), and the best optimization for threads is a listener thread per server (auth/game), one or two I/O workers (receiving data), and a threadpool of worker threads for processing clients' requests provided that the threadpool will spawn/abort threads as number of requests increase/decrease.
Then for proper database usage a multi-threaded core with a thread-safe queue for queries sounds like a good deal.
As for events etc a thread or two spawning other threads as needed is a good strategy as well.
|
|
|
09/27/2010, 14:25
|
#10
|
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 506
|
Some of you have to keep in mind RAM != CPU.
|
|
|
09/27/2010, 18:40
|
#11
|
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
|
Quote:
Originally Posted by Basser
Some of you have to keep in mind RAM != CPU.
|
well these threads could also use ram couldn't they?
|
|
|
09/27/2010, 18:43
|
#12
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
Quote:
Originally Posted by Basser
Some of you have to keep in mind RAM != CPU.
|
.
|
|
|
09/27/2010, 21:20
|
#13
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
Quote:
Originally Posted by ryuchetval
well these threads could also use ram couldn't they?
|
My concern with the threads was mostly for creating memory leaks. Spawning threads uses up some amount of ram (fairly small from what I remember hearing) but the main concern/advantage of managing your threads is to make processing fast and efficient.
Ram more becomes an issue when you are not disposing objects and over the course of your server, you are getting more and more ram usage. Aka a memory leak.
In most co servers your ram usage should remain fairly low unless you are doing something really strange. Loading dmaps, itemtypes, mob spawns and alike should NOT be using some fantastic amount of ram and if it is... you should track down which is using that amount of ram and fix the problem.
EG: try loading only 1 thing at a time and check ram usage.
|
|
|
09/27/2010, 22:28
|
#14
|
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
|
ok now after we talked so much about threads and others i remembered that i used an anti bot system released on here : 
could this be the problem of the memory leak as it's a timer not a thread...even though i don't know what i really say and i don't really know the difference between a timer and a thread if there is any...
|
|
|
09/27/2010, 22:45
|
#15
|
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
|
You can't get a true memory leak in C# unless you SERIOUSLY **** up (or get ****** by Microsoft unknowingly, which I doubt will happen to any of you guys).
The only way to get a true memory leak is by calling native functions and then not calling the functions to clean up native resources.
|
|
|
Similar Threads
|
SV Usage Guide?
08/05/2009 - Conquer Online 2 - 1 Replies
Before you flame me for posting about SV, READ my post!
I'm not looking for a cracking guide or any of that jazz, Just a simple usage guide, there is one for a really old version of SV, but it's nowhere near the same functions as the current version. I have a purchased account with SV, and Some of the manual isn't very clear due to bad translation, and mostly with the item pickup options and a few other parts of the bot I'm not completely clear with how they work, If anybody has a link to a...
|
Reduce RAM Usage for SRO
07/01/2009 - Silkroad Online - 6 Replies
#Links edited
|
WTB (BOT) TAXI/usage
11/14/2008 - Silkroad Online Trading - 5 Replies
heyy everyone i wana buy a bot usage for who ever has multi client like i give you my acc an you bot it for me(leave your offers for how long)
|
All times are GMT +1. The time now is 01:35.
|
|