MySQL: Storing result but not freeing. - 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: MySQL: Storing result but not freeing. (
/showthread.php?tid=274989)
MySQL: Storing result but not freeing. -
Tee - 07.08.2011
Well I used the mysql_debug(1) function to see what's going on in my script. I noticed that it stored the result even though I don't have anything in that table, but it did not free it, I'm wondering if that could cause a memory leak.
This is what a normal query of mine would look like:
pawn Код:
format(vfile,sizeof(vfile),"SELECT * FROM vehicle2 WHERE Owner = '%s' LIMIT 1",escape);
mysql_query(vfile);
mysql_store_result();
if(mysql_num_rows() != 0)
{
mysql_free_result();
GetVehiclePos(CarSystem[playerid][vID][1],X,Y,Z);
GetVehicleZAngle(CarSystem[playerid][vID][1],A);
format(String,sizeof(String),"UPDATE vehicle2 SET vModel = %d, XSpawn = %f, YSpawn = %f, ZSpawn = %f, Angle = %f WHERE Owner = '%s'",GetVehicleModel(CarSystem[playerid][vID][1]),X,Y,Z,A,escape);
mysql_query(String);
format(String,sizeof(String),"UPDATE vehicle2 SET vMod0 = %d,vMod1 = %d,vMod2 = %d,vMod3 = %d,vMod4 = %d,vMod5 = %d,vMod6 = %d,vMod7 = %d,vMod8 = %d,vMod9 = %d,vMod10 = %d,vMod11 = %d,vMod12 = %d WHERE Owner = '%s'",
CarSystem[playerid][vMods2][0],CarSystem[playerid][vMods2][1],CarSystem[playerid][vMods2][2],CarSystem[playerid][vMods2][3],CarSystem[playerid][vMods2][4],CarSystem[playerid][vMods2][5],CarSystem[playerid][vMods2][6],CarSystem[playerid][vMods2][7],CarSystem[playerid][vMods2][8],CarSystem[playerid][vMods2][9],CarSystem[playerid][vMods2][10],CarSystem[playerid][vMods2][11],CarSystem[playerid][vMods2][12],escape);
mysql_query(String);
}
Please ignore the indentation, the forum messed it up -_-
Note: I don't have anything in the 'vehicle2' table. Should I still add 'mysql_free_result even though I don't have it, the result was stored......
If you want to see the log I'll provide it.
Re: MySQL: Storing result but not freeing. -
Calgon - 07.08.2011
It won't cause a memory leak because there's nothing to store. You can't free an invalid result as I said before, so you're fine.
Also, you should consider posting your questions in the release topic of the plugin you use - people might end up confusing the two major plugins and give you incorrect advice. Plus, I'm subscribed to that thread [or at least G-sTyLeZzZ's release] so I get an email whenever anyone replies to it, so I'm usually quick to help, as well as loads of others.
Re: MySQL: Storing result but not freeing. -
Tee - 07.08.2011
Thanks, Calg00ne, and can I add you on MSN just for this issue?