Perl uses reference counting rather than garbage collection. So memory is freed as soon as the last reference is removed. The drawback is that data that refers back to itself never gets freed. You need to use tools such as Devel::Leak to track down the memory leaks. Once you're properly freeing memory, your problem should go away.