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:
- How garbage collector works?
- How memory leak still shows up?
- What is weak reference?
- 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:
- 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.
- Garbage collection takes time and resource to do it and sometimes it is not acceptable for the real-time mission critical system.
- 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. - It is also desirable that a garbage collector operate efficiently, without introducing long pauses during which the
application is not running.
When we talk about SOA, I would think of Amazon. It is the company that takes SOA to the next level, proving to the world that it is a viable solution for us. Great! I decide to put sometime to learn from Amazon via reviewing the web services it provides, reading the related interviews and blogs, studying how to build an application on top of its infrastructure, develop an application to consume data provided from its Web Services. Anyway, I believe the best way to learn SOA is to get a taste of the services provided from a company that relies greatly on this to scale its business. Before I delve deeper, I need to clarify one thing. Many people use the term SOA and Web Service interchangeably. Be honest, I was among one of them. However, in definition, they are not the same. 