Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
clsSocket verrs System
#1
I just got a out of memory error on this line of code

Code:
Call mvarSocket.Write(dbytes, thenShutdown)
That code is located in:
Code:
Public Sub WriteBytes(dbytes() As Byte, Optional thenShutdown As Boolean)
  Call mvarSocket.Write(dbytes, thenShutdown)
End Sub

And WriteBytes are called from a timer with the interval 3 for some reason:
Code:
Private Sub Timer1_Timer()
Dim i As Integer
Dim TmpStr As String
Dim dbytes() As Byte

    For i = 1 To MAX_PLAYERS
      TmpStr = vbNullString
      With ConQueues(i)
        If Not .Lock Then
            On Error Resume Next
            If GameServer.Sockets(i).Socket Is Nothing Then
                .Lines = vbNullString
            End If
            If Len(.Lines) = 0 And QueueDisconnect(i) = True Then
                Call CloseSocket(i)
                QueueDisconnect(i) = False
            Else
            If Len(.Lines) > 0 Then
               If Len(.Lines) < MAX_PACKETLEN Then
                 TmpStr = .Lines
               Else
                 TmpStr = Left$(.Lines, MAX_PACKETLEN)
               End If
               .Lines = Right$(.Lines, Len(.Lines) - Len(TmpStr))
            End If
          End If
          If Len(TmpStr) > 0 Then
            dbytes = StrConv(TmpStr, vbFromUnicode)
            If IsConnected(i) Then
                GameServer.Sockets(i).WriteBytes dbytes
                DoEvents
            End If
          End If
        End If
      End With
    Next
    DoEvents
End Sub
As I said, Out of Memory. And would like to know what could be the possible cause of it. For some reason, this is eating up all my RAM, of course my computer hasn't been restared in like 3-5days and only have 700+RAM on my server computer. But I don't think this should happen anyway. I remember talking with verr about the interval on the timer. It should be low but we couldn't decide how low really. I guess I will attempt to change it to 10-15ms.
Reply
#2
You have a memory leak somewhere. Memory leaks can be caused by loads of things, so you might want to check your source for any obvious ones. One possible memory leak which I just found out the other day is exiting a sub/function while you are still in a with statement, for example :

Code:
With Map
   x=.x
   y=.y
   exit sub
end with

Another tip would be to download a code profiler (such as this one : http://www.aivosto.com/project/project.html). However, many of these are expensive, so good luck finding a free one. I don't remember if CodeSMART finds memory leaks, if it does, you can use that Smile
Reply
#3
Hum, I guess I need to do this.. *boring*
Reply
#4
William Wrote:Hum, I guess I need to do this.. *boring*

Aha yeah, it's definitely boring looking for memory leaks. I just checked out CodeSMART and it does give you some memory leaks, so you can try that if you want, might save you lots of time :wink: Plus it optimizes most of your code anyways, which is always useful Smile
Reply
#5
Im not gonna let CodeSmart fuck up my code by changing things. Can that really be trusted?
Reply
#6
I got a message on the computer saying my virtual memory was low.
Reply
#7
Delete your porn. Need more memory.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#8
Robin Wrote:Delete your porn. Need more memory.
It's my server computer, it uses Windows Server 2003 and rarely has anything fun on it. Except my awesome server.
Reply
#9
Out of Memory typically means out of system memory A.K.A. you're using too much Ram. Like I said, your server has a memory leak. Don't worry, you can turn off some things in CodeSMART and you can also make it so it only leaves a suggestion (in a comment) on what the problem is and how to fix it.

EDIT: Sorry about that, meant CodeFixer all along, not CodeSMART. Here's a link : http://www.pscode.com/vb/scripts/ShowCo ... 7&lngWId=1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)