This was i nice and fun session.
If you just want to remember one thing from this its: DONT use finalize method for anything in java. The other things are normal memmory misuse stuff.
1. Always declare an Collection(impl) to an approx size of what u want, it not as sheap as one thinks to resize collections.
2. Small, immutable objects are really fast for the GC. Dont be clever and create them outside the loop or the normal life scope of the variable. Do not create generic variables that are nullified and reused in a method or loop.
3. Be aware of actionlisteners these keep reference to our instance and can create memmory leaks. This kind of behaivure is not as uncommon as one might think, even others than the AWT-tam make these kinds of programs.
4. If unclear dont use finalize, ever. DONT use them. If something like this i really needed, no other way can solve the problem, then use Reference classes(java.lang.ref.PhantomReference) and wrap the instance that needs this.
There were more tips, but i cant remember them all.
Friday, May 11, 2007
- ▼ May (9)