Memory Leaks:

Problem #1:

  • Lapse Event Listeners:
  • AWT Swing
  • Event Listener Design

Solution #1:

  • remove listener
  • shorten object life cycle
  • soft/weak references

Problem #2:
Leak Collections:

  • cache
  • session state
  • user interface
  • EJB container

Solution #2:

  • search for common warning signs
  • aggresively pair adds with remove
  • use soft references for cache
  • use finally
  • use collections with weak references

Ref:
Plugging memory leaks with weak references
Plugging memory leaks with soft references

Advertisements