OO Programming in Java

Class 9 Material


Thermostat



The Desired Topic Winner ............

RMI 14

Garbage Collection / Real Time Issues

JavaSoft VM Specification ...

" .... memory layout of runtime data areas, the garbage-collection algorithm used, and any optimizations of the bytecodes are left to the discretion of the implementor"


This is why details are a little vague. EmbeddedJava (and perhaps PersonalJava) may have an API to standardize how GCs function.


Sun's EmbeddedJava Web Page ....

"Another design goal of real-time embedded applications such as network routers and switches, is to preserve the real-time support offered by the hardware in the final product. In other words, fine granularity performance is required. For this reason, EmbeddedJava is designed to be used on top of a real-time operating system. Performance and porting considerations are built into its design. "

Called by:

Runtime.getRuntime().gc();

or

System.gc();

Finalization

The garbage collector automatically frees up memory resources used by objects. Some objects may hold system resources like file descriptors or sockets. Finalizer methods can help you take care of freeing these resources.

protected void finalize() {
    // release resource
}

Finalizer methods are written as shown above and are invoked by the system jjust before GCing.