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

Memoty leak detected in plugin


Post New Thread Reply   
 
Thread Tools Display Modes
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 05-09-2011 , 12:06   Re: Memoty leak detected in plugin
Reply With Quote #11

You have three ways how to close data timer handles:

  • Pass TIMER_DATA_HNDL_CLOSE as timer flag when creating the timer, the handle will be closed automatically then.
  • Close the handle yourself with CloseHandle()
  • pass true as second parameter when killing the timer with KillTimer()
All of the ways mentioned above will close the datatimer's data handle.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-09-2011 , 12:18   Re: Memoty leak detected in plugin
Reply With Quote #12

Quote:
Originally Posted by berni View Post
You have three ways how to close data timer handles:

  • Pass TIMER_DATA_HNDL_CLOSE as timer flag when creating the timer, the handle will be closed automatically then.
  • Close the handle yourself with CloseHandle()
  • pass true as second parameter when killing the timer with KillTimer()
All of the ways mentioned above will close the datatimer's data handle.
The whole point of using the CreateDataTimer stock is that you don't not need to worry about doing any of the above. It handles it for you.

His suspected issue was doing something similar to:
Code:
new Handle:pack = CreateDataPack(); CreateDataTimer(time, pack)  // this was creating a pack itself, leaving the one above unused and accumulating
psychonic is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 05-09-2011 , 13:31   Re: Memoty leak detected in plugin
Reply With Quote #13

So what's TIMER_DATA_HNDL_CLOSE good for then ?
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-09-2011 , 14:01   Re: Memoty leak detected in plugin
Reply With Quote #14

Quote:
Originally Posted by berni View Post
So what's TIMER_DATA_HNDL_CLOSE good for then ?
In case you prefer to do it manually instead of using the included stock.

From timers.inc
Code:
stock Handle:CreateDataTimer(Float:interval, Timer:func, &Handle:datapack, flags=0) {     datapack = CreateDataPack();     flags |= TIMER_DATA_HNDL_CLOSE;     return CreateTimer(interval, func, datapack, flags); }
psychonic is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 05-09-2011 , 14:14   Re: Memoty leak detected in plugin
Reply With Quote #15

That means it would only do it if you don't specify your own flags,
in case you specify TIMER_REPEAT or TIMER_FLAG_NO_MAPCHANGE you also have to add | TIMER_DATA_HNDL_CLOSE to it.

The CreateDataTimer() function is confusing a shitload of people by the way
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-09-2011 , 14:35   Re: Memoty leak detected in plugin
Reply With Quote #16

Quote:
Originally Posted by berni View Post
That means it would only do it if you don't specify your own flags,
in case you specify TIMER_REPEAT or TIMER_FLAG_NO_MAPCHANGE you also have to add | TIMER_DATA_HNDL_CLOSE to it.
No, with CreateDataTimer, you give it whatever other flags you want, if any. You can include TIMER_DATA_HNDL_CLOSE if you want, but it's not needed. It will get added automatically to whatever flags are given to it. You are only ever required to add the TIMER_DATA_HNDL_CLOSE if you want SM to automatically close the handle for you and you are not already using CreateDataTimer.[/QUOTE]

Quote:
Originally Posted by berni View Post
The CreateDataTimer() function is confusing a shitload of people by the way
What it does is noted in the function doc above the actual stock (which of course also shows the logic). The function doc is visible on the api site, and there is also a detailed example of it on the wiki.

The documentation is only good if you read it.
psychonic is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 05-09-2011 , 14:44   Re: Memoty leak detected in plugin
Reply With Quote #17

Quote:
Originally Posted by psychonic View Post
No, with CreateDataTimer, you give it whatever other flags you want, if any. You can include TIMER_DATA_HNDL_CLOSE if you want, but it's not needed. It will get added automatically to whatever flags are given to it. You are only ever required to add the TIMER_DATA_HNDL_CLOSE if you want SM to automatically close the handle for you and you are not already using CreateDataTimer.
Oh yeah I get it now.

Quote:
Originally Posted by psychonic View Post
What it does is noted in the function doc above the actual stock (which of course also shows the logic). The function doc is visible on the api site, and there is also a detailed example of it on the wiki.

The documentation is only good if you read it.
I know.

ffs you bugged the quote
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni 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 20:26.


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