SA-MP Forums Archive
[Help] How to find memory leak? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] How to find memory leak? (/showthread.php?tid=253331)



[Help] How to find memory leak? - lolumadd_ - 06.05.2011

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.


Re: [Help] How to find memory leak? - lolumadd_ - 06.05.2011

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


Re: [Help] How to find memory leak? - Donya - 06.05.2011

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


Re: [Help] How to find memory leak? - lolumadd_ - 06.05.2011

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


Re: [Help] How to find memory leak? - Donya - 06.05.2011

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


Re: [Help] How to find memory leak? - lolumadd_ - 06.05.2011

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


Re: [Help] How to find memory leak? - lolumadd_ - 06.05.2011

bump


Re: [Help] How to find memory leak? - Donya - 06.05.2011

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