The WeakReference class, monitoring memory leak and garbage collection in a Java application

Image
 Below is a Stack implementation that uses an internal resizeable array structure.  public class MyStack< T > implements Stack< T > { private static final int CAPACITY = 100 ; private Object[] array ; private int pos = 0 ; public MyStack () { this . array = new Object[ CAPACITY ] ; } @Override public void push ( T item) { if ( pos >= array . length / 2 ) { Object[] newArray = new Object[ pos * 2 ] ; System. arraycopy ( array , 0 , newArray , 0 , array . length ) ; array = newArray ; } array [ pos ++] = item ; } @Override public T pop () { if (isEmpty()) { throw new RuntimeException( "empty stack" ) ; } @SuppressWarnings ( "unchecked" ) T item = ( T ) array [ pos - 1 ] ; pos -= 1 ; return item ; } @Override @SuppressWarnings ( "unchecked" ) public T peek...

Notes on Parallel Programming

In the past, the performance of microprocessors increased on average, 50% per year. In this period, you could simply wait to buy the next generation of microprocessors that will speed up your applications. But since 2002, single processor performance has slowed down. By 2005, most manufacturers decided to go on in the direction of paralellism. They started to put multiple processors on a single circuit.

But this does not magically improve the performance of serial applications. It may be a silly question to ask: why do we need ever increasing performance? But why do they manufacture multi-core hardware? Because as the speed of transistor increase, so does the power consumption. The circuit becomes too hot and is not reliable anymore. And if the integrated circuit industry stop producing new and better products, those companies dissapear. So today, CPU clock speed is not increasing, and manufacturers does not design complex processors.

Most of the time, it is not possible to automatically convert serial programs to parallel programs. We need to find better algorithms that use parallelism.

In the classical Von Neumann architecture, there is a CPU, a memory and the interconnection between them. The seperation of memory and CPU is a bottleneck. Today CPUs can execute instructions more than one hundred times faster than they can read items from main memory.

To be continued..

Comments

Popular posts from this blog

Trie Data Structure and Finding Patterns in a Collection of Words

My Crappy Looking Solution to "Binary Tree Common Ancestor" Problem

A Graph Application in Java: Using WordNet to Find Outcast Words