troubleshooting Question

memory leak: which is better?

Avatar of royjayd
royjayd asked on
Java
16 Comments5 Solutions297 ViewsLast Modified:
hi guys

which is better? case1 or case2. will any of them cause memory leaks?

case1
public class ManagerBusinessService extends BaseBusinessService{//defined globally
//defined globally
private Workflow workflow;
private WorkflowDTO worflowDTO = null;

private WorkflowDao workflowDao;
public void setWorkflowDao(WorkflowDao workflowDao) {
this.workflowDao = workflowDao;
}

public WorkflowDTO fetchDetailsTx(String Id){                   
int workflowId = 0;            
flexworkfloId = getWorkflowNumbers(Id);                  
workflow = workflowDao.loadWorkflowDetailsTx(flexworkfloId);      
worflowDTO = WorkflowDetailAdapter.getInstance().transformDbModelToDTO(workflow);            }
return worflowDTO;
}
...

case2
public class ManagerBusinessService extends BaseBusinessService{
private WorkflowDao workflowDao;
public void setWorkflowDao(WorkflowDao workflowDao) {
this.workflowDao = workflowDao;
      }

      
public WorkflowDTO fetchDetailsTx(String Id){
//defined locally
Workflow workflow;
WorkflowDTO worflowDTO = null;                   
int workflowId = 0;            
flexworkfloId = getWorkflowNumbers(Id);                  
workflow = workflowDao.loadWorkflowDetailsTx(flexworkfloId);      
worflowDTO = WorkflowDetailAdapter.getInstance().transformDbModelToDTO(workflow);      
}
return worflowDTO;
}
...
ASKER CERTIFIED SOLUTION
Mick Barry
Java Developer
Join our community to see this answer!
Unlock 5 Answers and 16 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 5 Answers and 16 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros