Friday 15 April 2011

resources - Java closing/cleaning up -


I have a class in which there are some large objects:

  public class MyClass { BigObject bo; Public MyClass () {...}}   

Should I make a close approach like the following:

  public zero-off () {bo = Null; }   

I think this is good for garbage collection (?) Am I on the right track? How should I go for cleaning this class?

I think this is good for garbage collection

No, it just masers the code.

What is the catchover of the example of MyClass ? If you need an example of MyClass to stay alive but is not Big Object then - and only then - can you BO Setting should be bothering zero But at the same time, you should consider your design. Generally, all states of one class are important for its lifetime. There are exceptions to that rule, but they are relatively rare.

When the example of MyClass is eligible for garbage collection, its BO variable will be irrelevant to whether the BigObject Example of is eligible for garbage collection, so it does not matter if it is not empty or not ... but it does clean up after you manually To try, write a large difference in the context of the not code. They may have.

You should clear resources such as currents, country handles etc. - but usually you can handle the garbage collector with the memory.

No comments:

Post a Comment