Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Tuesday, July 13, 2010

Garbage Collection


Garbage Collection is the concept of collecting useless "dereferenced" memory, and freeing it for re-use by the system. De-referenced resources are those objects that are no longer in use by the program but are still allocated for use by it.

Languages like C/C++ could allow programmers to directly interact and play with memory, a responsibility that is often so abused that it does more harm than good... Problems arise when people recklessly allocate large system resources and the due to some mis-management the allocated memory is never freed. This leaves large chunks of unreacheable memory locations that ultimately cause "Memory Leaks". In comes the invention by John McCarthy, which shoulders the responsibility of memory management by de-allocating memory that is not in use by the program anymore. While the concept was initially developed for LISP only, now it has spread to a variety of High Level Languages, including updated versions of C\C++ themselves.
C++/CLI (Common Language Infrastructure), which is Microsoft's language specification has provision for both manual and automated memory management.

Garbage collector is the term used to represent automatic memory management by the system. Garbage collector scans the runtime environment for objects that are accessible directly or indirectly via references. Then it proceeds to discard all remaining objects. Typically, an object's memory is reclaimed when the number of references to it reaches zero. These scans are done in cycles, which are started automatically by the Garbage collector or when explicit calls are made to it.

Garbage collection does not guarantee immunity from memory leaks, and obviously requires a considerable percentage of system resources to run, but definitely helps programmers who have to deal with a lot of memory in their projects. Garbage collection is not commonly used in embedded projects due to their already small resource size but are available on certain platforms like .NET Micro Framework and Java-ME.

Monday, July 12, 2010

JAVA, A Revolution

Java as we know...is the current "Queen Bee" of languages, emerging not only as an OOPs based language but also a dynamically improving technology.
Java is not just one single language, but also an approach that lets you code for Servers(Java-EE), Portable/Embedded Devices(Java-ME), Standard software applications(Java-SE) and much more...

Java also introduces a Garbage collector that consumes dereferenced memory and provides an optimised environment where the computer, not the programmer manages the memory. More helpful is the JVM-Java Vitual Machine that is an abstract, virtual computer that run the compiled programs as "bytecodes", just as our computer accepts "Assembly language".

Major features:
- Portable - Runs on a variety of CPU's. Java can run on any system with a compatible JVM.
- Robust - Can be made so to withstand and survive crashes and exceptions.
- Secure - No pointers prevent malicious activity.
- Object Oriented - The whole program is encapsulated in a class.

Currently Java is seen as two distinct modules:

1) CORE-JAVA
- Fundamentals of OOPs
- Implementation of the language
- Basic Console Applications
- Basic GUI
- Applets

2) ADVANCED-JAVA
- Advanced features of java built over the core
- Solutions to dynamic problems
- Covers web, networking, DCOM or database handling

The reason why Java is gaining popularity is its ability to relate to reality...as with all Object Oriented Languages. Today Java is seen as the answer to many complex problems that exist in the real world.