Why does Perl not garbage collect memory when a large array is deallocated?

前端 未结 2 1148
迷失自我
迷失自我 2021-02-07 13:03

I know that Perl uses reference count based garbage collection. When a variable goes out of scope, the reference count is decremented and if REFcount goes to 0, the memory is de

2条回答
  •  面向向阳花
    2021-02-07 13:26

    Perl may have marked the memory as freed, but it doesn't necessarily mean that it has been freed back to the OS. Your Perl program may reuse that memory. Try running func again. You shouldn't see an increase in the amount of memory used.

    You may want to set the environment variable PERL_DESTRUCT_LEVEL and see if that makes any difference, but I doubt it.

    Garbage collection is not one of Perl's greatest strengths.

提交回复
热议问题