memory leaks - How can I completely delete a package in Perl? -


How can you completely remove a package in Perl? This does not mean that only package variables, but also any table of masses, which is updated to control legacy change and other things in Perl.

This simple test:

  Use warnings; Strict use; Test :: Lucres; Use the symbol 'delete_package'; Lectressress {package test; Our $ x = 1; Package head; Delete_package 'test'; }; Results in the following output:  
  LL.R / Parle 5 / 5.10.1 / Symbol.pm line 166 is ARRA (0x81c930) leak. Leak Hash (0x827760) /lib/perl5/5.10.1/Symbol.pm from line 166. / Lib / perl5 / 5.10.1 / Symbol.pm line 166 to scaler (0x821920) leaks. As a result, I can post on the request as a result of the data used by the flag for   

-burbos to lectress .

If line our @ isa = 'main'; has been added to the test package:

  ALLL (0x81cd10) leak AIPL line 32. Leak Scanner (0x81c930) so.pl to line 32 So.pl Leak ARRA (0x8219d0) from line 32. So.pl hash leaked from line 32 (0x8219c0). So.pl leak scaler (0x8219b0) from line 32. Leak HSH (0x8219a0) So.pl From Line 32 / Lib / perl5 / 5.10.1 / Symbol.pm Leak SCALAR (0x821970) from line 161. So.pl Leak HSH (0x821950) from line 32. Leak Scaler from So.pl (0x821940) Line 32.  

Line is 32 where is our @ ISA .

It is not obviously the noise from the lecture, it is actually leaked:

  my $ num = 0; While (1) {no strict 'refs'; @ {$ Num. ':: ISA'} = 'main'; Delete_package $ num ++; }  

will consume memory at a constant rate

So, what better way to get rid of any package than symbol delete_package is?

I have seen the same behavior in 5.8.8, 5.10.1 and 5.12

So this is a bug in Perl, a report has been made, as you found that fixing decreases, it seems that the only way to avoid these leaks is to choose another approach to solve your problem.

For example, instead of closing, do you need a semi-anonymous package? They are not very easy, with some creativity, and yet you can apply every external interface to them at the top, for example, by blessing your closed coderefs and providing methods for them, by providing overloading for them Can, etc. / P>


Comments