AS3 try to catch hard?

Why is using try catch bad for application performance?
I am not talking about using try catch 100 times. In fact, when I use it thousands of times.
Does this really cause performance problems?

thank you

+4
source share
3 answers

When talking about using exceptions as general practices, keep in mind that exceptions are "exceptional." As long as you use them so that they are designed to handle events that should not happen, everything should be fine.

So, do not try to use Exceptions for branching, implementing routines, or passing information around, and this should not affect performance. Even if it is heavy, it should be called once for a long time. Or, preferably, never at all.

+3
source

try / catch (as an anonymous function) will create an Activation object that will use more memory and will not use case for your local variable. Therefore, its use will consume memory and slow down its entire function .

You can see avm2 performance PDF , for example, he did not talk about try / catch, but you can see the chapter on method closure, where an anonymous function is described and uses the same mecanism for try / catch.

+4
source

Yes, the try and catch statement is very slow (compared to other operations) when it catches an error. Obviously, it has its purpose, but never relies on a try and catch statement for logical control. It exists to protect code where an error has a probability of occurrence (for example, an IO file).

+1
source

All Articles