Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Monday, November 19, 2007

Manual java deallocation

The area of memory where blocks are dynamically allocated is called the heap. In many programming languages (eg, C++) the programmer generally has to keep track of allocations and deallocations. Manually managing the allocation and deallocation (freeing) of memory is not only difficult to code, it is also the source of a large number of extremely difficult to find bugs. It is estimated that a very large percentage, I've seen estimates as high as 50%, of the bugs in delivered, shrink-wrapped, software are related to memory allocation/deallocation errors. There are two common bugs.

  • Dangling references. When memory is deallocated, but not all pointers to it are removed, the pointers are called dangling references -- they point to memory that is no longer valid and which will be reallocated when there is a new memory request, but the pointers will be used as tho they still pointed to the original memory.
  • Memory leaks. When there is no longer a way to reach an allocated memory block, but it was never deallocated, this memory will sit there. If this error of not deleting the block occurs many times, eg, in a loop, the program may actually crash from running out of memory.

No comments:

Post a Comment

Archives