473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Where to start the try block and what's the overhead???

Hello,

this is something I've been asking myself for sometime ... and now I'd like
to clarify this point.
When should the try block start in a method??? What I mean is, does having
all the code instead of a smaller set of it inside a try clause add any
overhead???
What I'd like to understand is if, to be completely sure that no unhandles
exception will get to the user, I can place all the code inside a try block
and if this practice adds unnecessary overhead (memory usage, more cpu
cycles, etc.) or if having a smaller set of instructions instead of all the
code under a try has the EXACT SAME effect on resources (overhead).
Bob Rock
Jul 21 '05 #1
2 1147
Throwing and catching exceptions is the 'costly' thing. Just trapping them
in try/catch doesn't have any discernable effect.

In general though, you should only try/catch one or a few lines of code so
you can respond to something specific and do something to correct it.

HTH,

Bill
www.devbuzz.com
www.knowdotnet.com

"Bob Rock" <no***************************@hotmail.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
Hello,

this is something I've been asking myself for sometime ... and now I'd like to clarify this point.
When should the try block start in a method??? What I mean is, does having
all the code instead of a smaller set of it inside a try clause add any
overhead???
What I'd like to understand is if, to be completely sure that no unhandles
exception will get to the user, I can place all the code inside a try block and if this practice adds unnecessary overhead (memory usage, more cpu
cycles, etc.) or if having a smaller set of instructions instead of all the code under a try has the EXACT SAME effect on resources (overhead).
Bob Rock

Jul 21 '05 #2
Hi Bob,

In addition to Bill, I agree as he says, once when I told the same someone
said.

I start all my procedures wit a Try and end it with a catch End Try. Just
because I send them to clients and when there is an error they can report
the error I have set in the catch block.

I had no reply on that answer.

Cor
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Jonas Rundberg | last post by:
Hi I just started with c++ and I'm a little bit confused where stuff go... Assume we have a class: class test { private: int arr; };
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
3
by: Bob Rock | last post by:
Hello, this is something I've been asking myself for sometime ... and now I'd like to clarify this point. When should the try block start in a method??? What I mean is, does having all the code...
7
by: Mr. Mountain | last post by:
In the following code I simulate work being done on different threads by sleeping a couple methods for about 40 ms. However, some of these methods that should finish in about 40 -80 ms take as long...
2
by: msnews.microsoft.com | last post by:
Hello, I have the scenario. I m building an application either in asp.net or window application. This application is base on n-tier application model. Let us take example of Northwind Database in...
37
by: ales | last post by:
Hello, I have a problem with creation of new thread. The method .Start() of newly created thread delays current thread for 0 - 1 second. Cpu while delay occurs is about 5%. Any idea? Here...
5
by: Tiglath | last post by:
We are building a high performance system and suddenly the cost of using exception has been magnified. What is the actual cost of having a frequent call inside a try-catch block when the vast...
7
by: william | last post by:
My question is: Specific memory block where my pointer pointing to changed strangely, seemingly that no statement changed it. Here are two examples I got: ***********1***************** I was...
14
by: karthikbalaguru | last post by:
Hi, In the case of heap , to keep track of a single chunk of memory it requires 8 bytes of information. That is, it requires 4 bytes to hold the size, and 4 bytes to hold the pointer to the next...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.