Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What consumes RAM Client side?
#2
The RAM usage is mostly going towards the graphic files most likely. They are all loaded into memory and stick there.

CPU usage is probably due to a lack of Sleep in the game loop. I'll just steal what I PMed to William a while ago to prevent having to re-type it:

Quote:First, get the Sleep API declared.

http://allapi.mentalis.org/apilist/Sleep.shtml

Now, say this is your client's pseudo game loop:

Code:
Dim StartTime As Long
Dim ElapsedTime As Long

Do
StartTime = GetTickCount

'Do game loop

ElapsedTime = GetTickCount - StartTime
Loop


Now after you get the elapsed time per frame, check it in comparison to the frame rate you desire. I think MS already does something like this, but the "wait" loop is something like:

Code:
Do While (GetTickCount - StartTime) < (1000 / MyFrameRate)
DoEvents
Loop


If thats the case, then just put after the DoEvents a "Sleep 1".

The Sleep API just basically stops the application for X milliseconds, freeing up the resources. What is happening is I assume you're on a single-core CPU. Your client is sucking up all the CPU, and since it is the active window, Windows gives it the priority over the server.

It is also beneficial to those on a laptop since it keeps their CPU usage down, which means more battery life and less fan usage. Wink

Quote:I added the declare, but the only thing the client have remotly close to that code you posted is the fps cap:
Code:
' Lock fps
Do While GetTickCount < Tick + 33
DoEvents
Loop

Should I put sleep 1 below the doevetnts?

Quote:Yup, thats exactly it. So yeah, just add Sleep 1 below that DoEvents and you will no longer be an enemy of CPUs. Tongue
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)