Re: general performance question
- From: grasp06110 <grasp06110@xxxxxxxxx>
- Date: Wed, 30 Jan 2008 12:17:16 -0800 (PST)
Clearly there's no sense at any time in creating an object and then setting
it to null
Sometimes I declare a variable that is to point to a resource and set
it to null so that the resource can be released in a wider scope. For
example:
Connection conn = null;
try {
conn = ConnectionFactory.getConnection();
doSomethingWithTheConnection(conn);
} finally {
if(conn != null) {
conn.close();
}
}
The best practice is to not fool with this kind of optimization unless you
have hard data from a profiler that it's actually a problem.
Whole heartedly agree. On occasion, some will throw out performance
as an excuse when backed into a corner or feel that they must give
some sort of explanation. If a performance hit is claimed it should
be backed up with some kind of measurement.
John
.
- Follow-Ups:
- Re: general performance question
- From: Lew
- Re: general performance question
- References:
- general performance question
- From: Tobi
- Re: general performance question
- From: Matt Humphrey
- general performance question
- Prev by Date: Re: Selecting target CPU for thread
- Next by Date: package com.ibm.security.x509 does not exist
- Previous by thread: Re: general performance question
- Next by thread: Re: general performance question
- Index(es):
Relevant Pages
|