Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3 try catch is heavy?

Why using try catch is bad for application performance?
I'm not saying about using try catch 100 times. Actually when i use it thousands of time.
Is it really causes problems for performance?

Thank you

like image 786
Almas Adilbek Avatar asked Feb 25 '23 20:02

Almas Adilbek


2 Answers

try/catch (as anonymous function) will create an Activation object that will use more memory and will not use register for your local variable. So using it will eat memory and slow down the whole function using it.

You can look at the avm2 performance PDF for example it didn't talk about try/catch but you can look at method closure chapter where anonymous function are described and use same mecanism for try/catch.

like image 152
Patrick Avatar answered Mar 02 '23 15:03

Patrick


Speaking for using exceptions as general practices, keep in mind exceptions are 'exceptional'. As long as you use them for what they are meant for - handling events that shouldn't be happening, it should be fine.

So, do not try to use Exceptions for branching, implementing sub-routines or passing information around, and it shouldn't have an impact on performance. Even if it is heavy, it is meant to be called once in a long, long while. Or preferably, never at all.

like image 29
Extrakun Avatar answered Mar 02 '23 16:03

Extrakun