Garbage collection model, JAVA Programming

This assignment is about experimenting with the Java runtime system's garbage collection model, and comparing it with the C++ manual memory allocation model. Below is the Garbage Java class/program that creates Chair objects and counts the number of objects having been created. The Chair class defines a finalize method that is called when the Chair objects are garbage collected.

After having created the objects, the Garbage program has three options, triggered by command-line arguments: (1) "before": calls the garbage collector manually, then runs finalization methods, (2) "after": instructs the garbage collector to run all finalization methods without explicitly calling for garbage collection to occur, and finally (3) if no command line arguments are provided, the normal garbage collection procedure occurs, without any explicit call directing how it should proceed.

Part 1:

Run the Garbage program and observe how it behaves using each of the three cases described above. Explain the results in terms of how the garbage collection system is behaving in each case.

Part 2:

Write a similar program in C++ using pointers to Chair objects, where the implementation behaviour of the finalize method is put into a destructor. Explain what happens when all the objects are explicitly deleted, and when they are not. Explain the differences with some of the results you got in part 1.

Part 3:

Re-write the program written in part 2, this time using STL C++ auto_ptr pointers to Chair objects and do the same experimentation. Explain your results compared to the results you got in parts 1 and 2.

Posted Date: 3/2/2013 1:05:36 AM | Location : United States







Related Discussions:- Garbage collection model, Assignment Help, Ask Question on Garbage collection model, Get Answer, Expert's Help, Garbage collection model Discussions

Write discussion on Garbage collection model
Your posts are moderated
Related Questions
What is a local, member and a class variable? Variables declared within a method are "local" variables. Variables declared within the class i.e not within any methods are "m

To use the DispatchAction, follow these steps: ? Make a class that extends DispatchAction (instead of Action) ? In a new class, add a method for each function you need to per

The JMS provider handles security of the messages, data conversion and the client triggering. The JMS provider verifies the level of encryption and the security level of the messag

Explain the Three Benefits of Access Protection ? Access protection has three major benefits: 1. It permits you to enforce constraints on an object's state. 2. It gives a si

i need help

What is Event Handler works? An event handler is a command which is used to call a function when an event happens, such as the user clicking a button or mouse.

The method should printout line numbers from 1 to howmany in the previous format -ONLY WHEN is divisble by 3 but is should not oupt more then 3 numbers on the line. input 1 outpu

Need Java/JNLP Application - GUI and Backend Projects Project Description: I am looking for assistance in making changes to a complex java application. System launches fro

I need to draw cars and trucks and background with road and a house with sky. I have to use Vehicle class as a parent class. To draw pictures, i should draw fun things coming up

Develop a Client/Server (MySQL) student record application Project Description: I need a client/server application with a MySQL backend database. The prototype could interfac