in reply to Perl - release memory

It's possible, under certain circumstances. There's ton of threads about it here

The only 100% reliable way is to use some variant of exec($0).