Garbage collection model, JAVA Programming

Assignment Help:

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.


Related Discussions:- Garbage collection model

How does java allocate heap and stack memory?, Each time an object is start...

Each time an object is started in Java it goes into the area of memory named as heap. The primitive variables like double and int are allocated in the stack, if they are local inst

Differentiate between onload and onunload, Differentiate between onLoad and...

Differentiate between onLoad and onUnload? Onload executes the particular javascript code when a latest document is loaded into a windows. ONUnload executes he particular javas

Maintenance and administration activities, Maintenance and Administration a...

Maintenance and Administration activities: Name                        : e-Commerce OS and Soft wares    : Websphere 6.0, IHS, Unix, Weblogic 8.1   Maintenance an

Heap and Stack memory allocation in java, Each time an object is started in...

Each time an object is started in Java it goes into the area of memory named as heap. The primitive variables like double and int are allocated in the stack, if they are local inst

Write a program to add of doubles in java, Write a program to add of double...

Write a program to add of doubles in java? Doubles are treated much the similar way, but now you obtain to use decimal points in the numbers. This is a same program which does

What are the layers of rmi architecture, There are three layers:-  a . S...

There are three layers:-  a . Stub and Skeleton layer This layer lies just under the view of the developer. This layer intercepts method calls made by the client to the inte

What is meant through semantic error, What is meant through semantic error?...

What is meant through semantic error? It is an error that a developer encounters while a statement is executed but it was not intended through him (the developer). Such errors ar

Solving problems about traffic jam, Computer programming Project Descrip...

Computer programming Project Description: Solving various problems about traffic jam Skills required: C# Programming, Java, C++ Programming, PHP, Software Architecture

Write program for queue of cards, A Queue of Cards You are going to par...

A Queue of Cards You are going to parallel the development done in the lesson on inheritance where we constructed some base classes, StackNode and Stack, and derived  Floa

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd