I'm having some issues with the memory usage of a perl script I wrote (code below). The script initiates some variables, fills them with data, and then undefines them again. However, the memory usage of the script after deleting everything is still way to high to contain no data.

Accoring to `ps` the script uses 1.027 Mb memory (RSS) during the first 39 seconds (so everything before the foreach loop). Then, memory usage starts rising and ends up fluctuating between 204.391 Mb and 172.410 Mb. However, even in the last 10 seconds of the script (where all data is supposed to be removed), memory usage never goes below 172.410 Mb.

Is there a way to permanently delete a variable and all data in it in perl (in order to reduce the memory usage of the script)? If so, how should I do it?

```
use strict;
use warnings;

sleep(30);

my $ELEMENTS = 1_000_000;
my $MAX_ELEMENT = 1_000_000_000;
my $if_condition = 1;

sleep(5);

my %hash = (1 => {}, 2 => {}, 3 => {}, 4 => {});

foreach my $key (keys %hash){
    if( $if_condition ){
        my $arrref1 = [ (rand($MAX_ELEMENT)) x $ELEMENTS ];
        my $arrref2 = [ (rand($MAX_ELEMENT)) x $ELEMENTS ];
        my $arrref3 = [ (rand($MAX_ELEMENT)) x $ELEMENTS ];

        sleep(2);

        if(!defined($hash{$key}->{'amplification'})){
            $hash{$key}->{'amplification'} = [];
        }

        push(@{$hash{$key}->{'amplification'}},@{$arrref1});
        undef($arrref1);
        push(@{$hash{$key}->{'amplification'}},@{$arrref2});
        undef($arrref2);
        push(@{$hash{$key}->{'amplification'}},@{$arrref3});
        undef($arrref3);

        sleep(3);

        delete($hash{$key});

        sleep(5);
    }
}

sleep(10);

```