Difference between revisions of "User:DavidJCobb/Stack dumping"

m
imported>DavidJCobb
imported>DavidJCobb
Line 17: Line 17:
== Specific methods to minimize stack dumping ==
== Specific methods to minimize stack dumping ==
*There are a number of events that can rapidly generate suspended stacks, because they can occur several times in a short period (such that several calls to your event handlers are queued). If you must listen to these events, then minimize the length of your event handlers, so that the resulting stacks are executed as quickly as possible.
*There are a number of events that can rapidly generate suspended stacks, because they can occur several times in a short period (such that several calls to your event handlers are queued). If you must listen to these events, then minimize the length of your event handlers, so that the resulting stacks are executed as quickly as possible.
** Don't use Utility.Wait() in these event handlers. It will by definition make your event handlers take longer to execute.
** Don't use Utility.Wait(''n'') in these event handlers. It will by definition make your event handlers take longer to execute. For significant delays, calling [[RegisterForSingleUpdate - Form|RegisterForSingleUpdate(''n'')]] and returning (and doing the rest of your processing in OnUpdate) is a good alternative: your stack won't stick around during the wait time.
** Minimize the amount of times you access shared resources (such as the player), in order to shorten your event handler's overall execution time.
** Minimize the amount of times you access shared resources (such as the player), in order to shorten your event handler's overall execution time.
*** Remember that your own resources can be shared. If you have a magic effect that coordinates itself via a quest, anyone with that magic effect will be sharing that quest.
*** Remember that your own resources can be shared. If you have a magic effect that coordinates itself via a quest, anyone with that magic effect will be sharing that quest.
Anonymous user