Raised This Month: $12 Target: $400
 3% 

Memory leak - question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gemeni
Senior Member
Join Date: Sep 2007
Location: Sweden
Old 10-01-2008 , 17:05   Memory leak - question
Reply With Quote #1

Hiyas ...
Seems like one of my plugin has started to leak memory ... even though I havnt change the code in quite some time ...

The following shows up in cstrike/sourcemod_fatal.log

Code:
L 09/19/2008 - 11:57:27: [SM] MEMORY LEAK DETECTED IN PLUGIN (file "gem_damage_report.smx")
L 09/19/2008 - 11:57:27: [SM] Reloading plugin to free 15784 handles.
L 09/19/2008 - 11:57:27: [SM] Contact the author(s) of this plugin to correct this error.
What can cause this? Valve update? SourceMod update?

Is there a good way to trace this? I cant see anything regarding this in the sourcemod logfiles.

Thanks for any advice
__________________
--- Growing older is mandatory --
----- Growing up is optional -----
Gemeni is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 10-01-2008 , 17:35   Re: Memory leak - question
Reply With Quote #2

Sounds like you're not closing handles properly, causing them to leak. It's most likely been a problem for a long time, it just got really bad that once to where it actually gave you an error.
bl4nk is offline
DiscoBBQ
Veteran Member
Join Date: Jan 2005
Location: Clemson, South Carolina
Old 10-01-2008 , 22:00   Re: Memory leak - question
Reply With Quote #3

Make sure you use CloseHandle(Handle:Whatever); on any handles you open.
DiscoBBQ is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 10-02-2008 , 01:02   Re: Memory leak - question
Reply With Quote #4

Most handles you do not have to close, as they handle themselves... BUT... anytime you "create" or "new Handle:" a handle in a stock function you have to make sure that you close it properly.

Check this article for more information. Click Me!

Last edited by Antithasys; 10-02-2008 at 01:04.
Antithasys is offline
BAILOPAN
Join Date: Jan 2004
Old 10-02-2008 , 23:03   Re: Memory leak - question
Reply With Quote #5

Link to the plugin, I can take a look.
BAILOPAN is offline
Gemeni
Senior Member
Join Date: Sep 2007
Location: Sweden
Old 10-03-2008 , 01:54   Re: Memory leak - question
Reply With Quote #6

Thanks Bailopan

https://forums.alliedmods.net/showthread.php?t=64661
__________________
--- Growing older is mandatory --
----- Growing up is optional -----
Gemeni is offline
BAILOPAN
Join Date: Jan 2004
Old 10-03-2008 , 02:58   Re: Memory leak - question
Reply With Quote #7

Big leak in Event_PlayerSpawn

Code:
  // Temp fix menu   if (g_MenuCleared[client] == 0) {     new Handle:TempPanel = CreatePanel();     DrawPanelText(TempPanel, "DR Fix");     SendPanelToClient(TempPanel, client, Handler_MyPanel, 1);     g_MenuCleared[client] = 1;   }

Methinks SM should GC at some point. Or as a quick fix, attach line numbers to handles so they can be tracked down easier.
BAILOPAN is offline
Gemeni
Senior Member
Join Date: Sep 2007
Location: Sweden
Old 10-04-2008 , 10:20   Re: Memory leak - question
Reply With Quote #8

Attach line numbers?!
__________________
--- Growing older is mandatory --
----- Growing up is optional -----
Gemeni is offline
BAILOPAN
Join Date: Jan 2004
Old 10-04-2008 , 11:57   Re: Memory leak - question
Reply With Quote #9

FYI there is a command, sm_dump_handles

It will help you track down leaks in the future.
BAILOPAN is offline
Gemeni
Senior Member
Join Date: Sep 2007
Location: Sweden
Old 10-04-2008 , 17:16   Re: Memory leak - question
Reply With Quote #10

Thanks ...
The ironic in this is that the temp menu fix is not needed anymore. It was fixed in a SM release about a year ago ;)

But ... a question regarding closing pack Handles

In DisplayDamageReport I declare a new Handle:pack

It's used in a CreateDataTimer and as a "parameter variable" in DisplayDamageReportMenu

If I close the pack handle in DisplayDamageReport, I get handle errors from DisplayDamageReportMenu saying that pack handle is non existing.

So, is there any way I can close the pack handle? Should I do it in DisplayDamageReportMenu? Or is it closed by default when that procedure finishes?
__________________
--- Growing older is mandatory --
----- Growing up is optional -----
Gemeni is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode