[Help] How to find memory leak?
#1

I am pretty sure I have a memory leak (never-ending loop) that causes my server to crash. After some time, usually in intervals of many hours (at least one a day), my server CPU will peak to around 90% +. At that time, my server freezes and it crashes.

I am pretty sure this is caused by a memory leak, if it is not, please suggest to me what else can be causing it. Can please someone give me an example of a common infinite loop. Or tell me what I should be looking for. I have tried debugging all of my loops, but it doesn't seem to give me any clues.

Thanks.
Reply
#2

I forgot to do a mysql_free_result() after storing, could that be the problem?
Reply
#3

just 1? 1 might just cause a mysql disconnection, i dont think it would've done all of that.. (BlueG's plugin)

for safer mysql mishaps

try
pawn Код:
public OnQueryError(errorid, error[], resultid, extraid, callback[], query[], connectionHandle)
{
    switch(errorid)
    {
        case CR_COMMAND_OUT_OF_SYNC:
        {
            printf("[Mysql Error] - Commands Out Of Sync For Thread ID: %d",resultid);
        }
        case ER_UNKNOWN_TABLE:
        {
            printf("[Mysql Error] - Unknown table '%s' in %s",error,query);
        }
        case ER_SYNTAX_ERROR:
        {
            printf("[Mysql Error] - Something is wrong in your syntax, query: %s",query);
        }
        case CR_SERVER_GONE_ERROR:
        {
            mysql_reconnect();
        }
        case CR_SERVER_LOST:
        {
            mysql_reconnect();
        }
    }
    return 1;
}
if '[Mysql Error] - Commands Out Of Sync For Thread ID: %d' happens, then the server crashes, then that thread is probably your problem
Reply
#4

What does that mean? Commands is out of sync? What would be an example that causes that?
Reply
#5

say you stored a result then did not free it, so the next mysql_query called/used, it would cause a command out of sync error, and not complete the query. you can bypass errors by using IGNORE which will make the errors into warnings, then use mysql_warning_count()..etc
Reply
#6

Well, even after I put in the mysql_free_result() where I didn't before, the server has still been crashing.
Reply
#7

bump
Reply
#8

try debugging some callbacks, make some prints at the start & end of each callback etc...

edit: also OnPlayerCommandText ? OnPlayerCommandReceieved(Zcmd) to debug each command called
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)