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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With