• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Leaks upon creation

Status
Not open for further replies.
Level 5
Joined
Feb 17, 2011
Messages
95
I've read all i could find about leaks, but there is still one thing that is bothering me. I have a timer to keep track of ability cooldown. So, is it more efficient to create timer once, on map initialization, and reuse it over and over, or to dynamically create/destroy timer every time when ability is used?
 
Last edited:
Level 5
Joined
Feb 17, 2011
Messages
95
i have not that much experience with timers, but i think create/destroying them in a short period of time could reduce the efficiency

The shortest time is 15 seconds, so i guess it wouldn't affect it.

I create them at Initialization via Variable Manager, and just use them... I had no efficieny issues whatsoever, and I used over 60 timers (not at the same time)... :)

I hoped for that answer, but the thing is that ability i'm making is not for a specific map, and i want it to be clear of all leaks for future use by me or someone else.
 
Last edited:
Level 28
Joined
Sep 26, 2009
Messages
2,520
memory leaks are pieces of memory that serve no purpose and cannot be accessed anymore (there's no pointer with their address).
They take little memory (very little), but if you have way too many of them, they pile up and later it can affect your game.

Having 1 timer that you use throughout the game is no memory leak per se, as you still have variable pointing to that timer and you use it - it still serves purpose.
 
Level 5
Joined
Feb 17, 2011
Messages
95
memory leaks are pieces of memory that serve no purpose and cannot be accessed anymore (there's no pointer with their address).
They take little memory (very little), but if you have way too many of them, they pile up and later it can affect your game.

Having 1 timer that you use throughout the game is no memory leak per se, as you still have variable pointing to that timer and you use it - it still serves purpose.

That's what i thought, thanks for clarifying.
And thank you all for commenting.
 
Last edited:
Status
Not open for further replies.
Top