The way to avoid memory leaks is to force garbage collection.