HomeBlogAboutTools

Garbage Collection

uncategorized

I had a discussion with a friend today about Garbage Collection. He has quite a “messy room” problem - his bedroom is so full of stuff that he couldn’t close the door for a few months, and spend 3 (?) weeks sleeping on the couch because there was too much stuff on the bed.

We decided that his problem was that his garbage collector isn’t doing minor collections of the new object eligable for GC, so they just lay around and wait for a major collection. However, there is so much garbage waiting for that major collection that the Mark-compact collection algorithm used there is continually fighting a loosing battle against the garbage.

We also decided that leaving stuff at a friends (or parents) house is actually a memory leak.

How am I going so far, Superman? ;-)

Also, does this code looks familiar to anyone else:


public class Superman implements Runnable {
	private boolean doneEnoughWork = false;
	private boolean feelingSmartToday = false;

	public void run() {
		while (!doneEnoughWork) {
			work();
		}

		if (feelingSmartToday) {
			// set the alarm object to interrupt this thread in about
			// 8 hours
			AlarmClock.set(Thread.currentThread());
		} else {
			// BodyClock is an unstable time keeping
			// mechanism and should be treated with caution.
			// It is designed for use on resource constrained VMs
			// such as the PrimativeMan embedded VM and the
			// WeekendVM
			//
			// It may interrupt the thread passed in roughly
			// 8 hours, plus or minus and hour or two.
			BodyClock.pleaseWakeMeUp(Thread.currentThread());
		}

		try {
			Thread.currentThread.sleep()
		} catch (InterruptedException e) {
			getUpAndGoToWork();
		}

	}
}