Recently I read about this topic and wanted to share it, I couldn’t recollect the source where I read it first to give a reference link, so just writing it here. When JVM requires memory, Operating System always allocates continuous memory blocks. When objects get created and destroyed frequently, JVM allocates memory where ever available. Think of a situation where 1000 [each of size 5bytes] objects got allocated in some ‘x’ time span and only 500 of them are killed/de-allocated. Memory occupied by these 500 objects might not be continuous, the de-allocated memory might me scattered across heap memory. Each de-allocated block is of size 5bytes – so, you might be having free memory block of size 5bytes across heap, if JVM wants to allocate a 10byte memory block it cannot use these 5bytes blocks, it has to find a continuous 10byte free space in heap and allocate it. This situation is called as " Heap Fragmentation " [same as ‘ Disk Fragmentation ’], where the heap memory is...
A techie who love to read, code and share ...