Code examples and code modules

Avoiding Memory Fragmentation

Be careful when allocating and de-allocating memory so that you are not creating unnecessary memory fragmentation by leaving many small memory holes that are not usable. These small holes are free memory and will be counted as such, i.e. calling the function Runtime.getRuntime().freeMemory() will return the amount of all free memory including the holes. However, this memory is unusable since the holes would be too small to hold the data objects.

Download Avoiding Memory Fragmentation (2.9 KB)