Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
|
11-18-2015
, 22:19
[TF2] Database Memory Leak
|
#1
|
Code:
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, iArg2, iArg3) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218640, 6, 6, 4, 'medic_shield_deployed_destroyed', 'Yanm', 3, 792, 1) ran successfully. (#102)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #134 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218644, 6, 6, 4, 'player_damage', 'Engineer', 15, 'TeamWork OP Volvo Please Nerf', 27, 17, 24, 0, 0) ran successfully. (#134)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #102 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218646, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Hydrogen', 2, 166, 18, 0, 0) ran successfully. (#102)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #102 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218646, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Hydrogen', 2, 166, 18, 0, 0) ran successfully. (#102)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #134 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218649, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Hydrogen', 2, 148, 18, 0, 0) ran successfully. (#134)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #102 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218649, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Hydrogen', 2, 148, 18, 0, 0) ran successfully. (#102)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #102 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218652, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Hydrogen', 2, 130, 18, 0, 0) ran successfully. (#102)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #134 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218652, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Hydrogen', 2, 130, 18, 0, 0) ran successfully. (#134)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #102 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218656, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Yanm', 3, 106, 2, 0, 0) ran successfully. (#102)
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query #102 completed successfully.
L 11/18/2015 - 20:46:40: [mvm_source_tv_feedback.smx] >>>> Query INSERT INTO EventTable (FileName, TimeStamp, Time, Tick, Wave, AttemptedWaves, RoundStatus, EventName, sArg1, iArg1, sArg2, iArg2, iArg3, iArg4, iArg5, iArg6) VALUES ('mvm_mannhattan_advanced1_1447894301', 1447897600, 3299, 218658, 6, 6, 4, 'player_damage', 'Giant Heal-on-Kill Heavy', 19, 'Hydrogen', 2, 52, 18, 0, 0) ran successfully. (#102)
L 11/18/2015 - 20:46:40: [SM] MEMORY LEAK DETECTED IN PLUGIN (file "mvm_source_tv_feedback.smx")
L 11/18/2015 - 20:46:40: [SM] Unloading plugin to free 32487 handles.
L 11/18/2015 - 20:46:40: [SM] Contact the author(s) of this plugin to correct this error.
L 11/18/2015 - 20:46:40: --------------------------------------------------------------------------
L 11/18/2015 - 20:46:40: Type IDatabase | Count 32486
L 11/18/2015 - 20:46:40: Type Timer | Count 1
L 11/18/2015 - 20:46:40: -- Approximately 0 bytes of memory are in use by (32487) Handles.
L 11/18/2015 - 20:46:40: [SM] MEMORY LEAK DETECTED IN PLUGIN (file "mvm_source_tv_feedback.smx")
L 11/18/2015 - 20:46:40: [SM] Unloading plugin to free 32487 handles.
L 11/18/2015 - 20:46:40: [SM] Contact the author(s) of this plugin to correct this error.
L 11/18/2015 - 20:46:40: --------------------------------------------------------------------------
L 11/18/2015 - 20:46:40: Type IDatabase | Count 32486
L 11/18/2015 - 20:46:40: Type Timer | Count 1
L 11/18/2015 - 20:46:40: -- Approximately 0 bytes of memory are in use by (32487) Handles.
[SM] Plugin [TF2] MvM Source TV & Feedback Recorder unloaded successfully.
Completed SourceTV demo "mvm_mannhattan_advanced1_1447894301.dem", recording time 3279.9
The code is basically 20 event hooks like this:
PHP Code:
HookEvent("player_hurt", OnPlayerTakeDamage); // Called when a player takes damage.
And the callback is like this:
PHP Code:
public Action OnPlayerTakeDamage(Handle EventHandle, const char[] EventName, bool DontBroadcast) { // Get a lot of information out from this event. int Victim = GetClientOfUserId(GetEventInt(EventHandle, "userid")); // Client index of the victim. int Attacker = GetClientOfUserId(GetEventInt(EventHandle, "attacker")); // Client index of the attacker. (0 = CONSOLE, like fall damage and environmental hazards) int Health = GetEventInt(EventHandle, "health"); // Victim's health remaining. int DamageDone = GetEventInt(EventHandle, "damageamount"); // Damage amount done to victim. bool Crit = GetEventBool(EventHandle, "crit"); // Is crit damage? bool MiniCrit = GetEventBool(EventHandle, "minicrit"); // Is minicrit damage? (If set to 1, crit is set to 1 as well.) // Get the names of both players: GetClientNameEscaped(Victim, Player1, sizeof(Player1)); GetClientNameEscaped(Attacker, Player2, sizeof(Player2)); // Now insert in everything: PartiallyFormatString(FixedDataString, sizeof(FixedDataString)); Format(QueryString, sizeof(QueryString), PLAYER_DAMAGE_EVENT_QUERY, FixedDataString, Player1, Victim, Player2, Attacker, Health, DamageDone, Crit, MiniCrit); // victim's name, victim's client index, attacker's name, attacker's client index, victim's leftover health, damage done to victim, is crit, is minicrit SQL_TQuery(FeedbackDatabase, Nothing, QueryString, 134); }
The callback is:
PHP Code:
public void Nothing(Handle DatabaseHandle, Handle QueryHandle, const char[] Error, int QueryCode) { if (!StrEqual(Error, "")) // error string not empty { #if defined DEBUG PrintToChatAll("SQL Error #%d: %s See console.", QueryCode, Error); // debug #endif LogError("SQL Error: %s (Query Code: %d)", Error, QueryCode); LogError("SQL Error: %s (Query Code: %d)", QueryString, QueryCode); } #if defined DEBUG else { LogMessage(">>>> Query #%d completed successfully.", QueryCode); // use this to check what queries have been executed successfully. LogMessage(">>>> Query %s ran successfully. (#%d)", QueryString, QueryCode); } #endif }
That's all this plugin is full of. There are no other handles present. There are no transactions. And it leaked. Why did it leak? Doesn't SQL_TQuery close all handles automatically? I'm confused right now. I also did Ctrl + F "Handle " to find handle declarations but there are only 2 unclosed GLOBAL database handles from OnPluginStart and there isn't anything that derives from Handle (methodmap-wise).
Thanks for any help!
Last edited by Potato Uno; 11-18-2015 at 22:22.
|
|