Archive | September 22, 2008

Java System Architecture Resources – Links

Memory Management

One strength of the Java™ 2 Platform, Standard Edition (J2SE™) is that it performs automatic memory
management, thereby shielding the developer from the complexity of explicit memory management. However, it doesn’t mean that there will not be any memory leak. So, I decide to give a summary on some key areas in this topics. They are:

  1. How garbage collector works?
  2. How memory leak still shows up?
  3. What is weak reference?
  4. What stores in heap and stack?

If you want to understand this topic in detail, you can read the this article from Sun. The key points are summarized below:

  1. Without automatic memory management – GC, we may face 2 common issues: dangling reference (deallocate a object while others are still referencing it) and space leak (some objects are not referenced but not been deallocated either). GC is great but it doesn’t solve all the memory allocation problem. For example, you can have object list keep growing until it uses up all the free memory.
  2. Garbage collection takes time and resource to do it and sometimes it is not acceptable for the real-time mission critical system.
  3. The task of fulfilling an allocation request, which involves finding a block of unused memory of a certain size in
    the heap
    , is a difficult one. The main problem for most dynamic memory allocation algorithms is to avoid
    fragmentation
    , while keeping both allocation and deallocation efficient. One approach to eliminating fragmentation is called compaction.
  4. It is also desirable that a garbage collector operate efficiently, without introducing long pauses during which the
    application is not running.

 

Leave a comment Continue Reading →