Cost of having try-catch statements?
Tue Aug 10 16:37:00 GMT 2004
Martin Egholm Nielsen writes:
> > > I was wondering: Is there any significant cost in having "unused"
> > > try-catches in my code?
> > > That is, I have a method that 99.99% of the times invoked never throws a
> > > given exception. However, in case it does, I need to log it...
> > The only cost is the unwinder tables, (which are not read into memory
> > unless your exception is thrown) and the handler itself, which may
> > cause some instruction cache presure.
> So practically no overhead?
That's the idea. Really, if there is any significant overhead for an
unused handler that would be a bug.
More information about the Java