1. A computer program product comprising a computer readable storage medium having computer program code embodied therein for: allocating memory space for an application as part of a garbage collection process using a read barrier; segmenting the memory space into a number of pages each of a predetermined size; dividing the pages into blocks of a plurality of predetermined sizes; identifying objects to be allocated; allocating memory for the objects into the blocks of a size class that is the smallest size class that accommodates the object; marking some of the objects as dead; removing the objects marked as dead; optimizing the read barrier using sub-expression elimination, the optimizing comprising: breaking up the read barrier; and performing a forwarding operation for a quantity used in a loop only once during execution of the loop; and defragmenting a part of the memory by moving the objects wherein a forwarding operation required to move the objects is performed with a read barrier as soon as a quantity to be forwarded is loaded, the part of the memory ranging in size from a fraction of the memory space to the entire memory space; such that overhead costs associated with using the read barrier are minimized.