In the SUN virtual machine there are two reasons why an OutOfMemoryError might occur, because the SUN VM uses two different memory blocks for allocating objects and for loading classes. So possible reasons are:
1. The VM cannot allocate memory for a new object because there is no space in the heap available.
2. A classloader tries to load a new class but cannot do so because
the perm space of the memory is full.