Exception handling and loitering references
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Aruna_Raghavan
Posted On:   Friday, March 29, 2002 02:09 PM

Hi,
I am writing a memory intensve java application. I set all my references to null as soon as I am done using them to prevent leakages and effective garbage cleanup. However, I am not sure what to do when exceptions are thrown. Ideally, I would like to handle them in the finally block but this means all of my local data needs to be defined out side my try catch block. I don't like having to go back to C style declarations. I enjoy having the flexibility of allocating my objects on a per need basis. Is there a good way to solve this problem?
Thanks a bunch!
Aruna.

Re: Exception handling and loitering references

Posted By:   Bozidar_Dangubic  
Posted On:   Monday, April 1, 2002 10:11 AM

not really. it is a good programming practice to declare your variables outside loops and try-catch blocks anyways. so declare them outside and use them inside if you want. you will not allocate any memory if you provide a simple declaration outside the loops and try-catch blocks and it will solve the problem you are currently having.
About | Sitemap | Contact