sneakyimp
03-02-2009, 09:45 PM
I have an application I've been working on that does some recursive directory searching and then performs a diff on various files. In the process of trying to calculate the diff of a large file, I run out of memory.
I'm wondering some things:
1) Do I need to destroy vars or set them to null in my code to try and preserve memory? Generally speaking, I try to declare variables as locally as possible and I try to avoid excessive use of global vars.
2) I noticed that when my directory listing routine is complete that it appears to have a lock on certain files -- i can't delete them until I have closed my Java app, for instance. Is there some way to get my code to let go of these files? For instance, if I create an instance of a class that has one private BufferedReader var, do I need to set the BR var to null when I'm done with the object? Note that this class instance is a var internally declared inside a static function.
3) Given that this exception occurred when a large file was being processed, is there a way to allocate more memory in general for my java app?
Any help would be much appreciated.
I'm wondering some things:
1) Do I need to destroy vars or set them to null in my code to try and preserve memory? Generally speaking, I try to declare variables as locally as possible and I try to avoid excessive use of global vars.
2) I noticed that when my directory listing routine is complete that it appears to have a lock on certain files -- i can't delete them until I have closed my Java app, for instance. Is there some way to get my code to let go of these files? For instance, if I create an instance of a class that has one private BufferedReader var, do I need to set the BR var to null when I'm done with the object? Note that this class instance is a var internally declared inside a static function.
3) Given that this exception occurred when a large file was being processed, is there a way to allocate more memory in general for my java app?
Any help would be much appreciated.