When should I be using "delete" on variables?
The wiki page about Handles clearly say that all handles should (must) be closed after use, as they reserve memory which should be freed. That's good to know.
But is this the only use for the "delete" statement? Are there no other situations in sourcepawn scripting where memory needs to be "manually" freed? |
Re: When should I be using "delete" on variables?
From the SM discord
https://i.imgur.com/Lg32rHI.png |
Re: When should I be using "delete" on variables?
Quote:
Quote:
|
Re: When should I be using "delete" on variables?
Quote:
|
Re: When should I be using "delete" on variables?
Some handles are automatically closed. When it's the case, it'll be mentionned.
Note though that handles that are automatically close will still have their reference (idk if it's the right term, I'll just call it like that)! A timer handle will be closed when you return Plugin_Stop in its function, but it won't set the variable value to null, so remember to do that (if you keep the Handle after the function is finished, ex: a global Handle for a timer)! Ex: Hander timerHandle = (reference) CloseHandle(timerHandle) removes the handle (pointed by the reference), but timerHandle is still equal to (reference), but this reference points to nothing, so you should always set it to null if you saved the Handle in a global variable! If you have any question, special case, or error, just ask :) |
| All times are GMT -4. The time now is 05:00. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.