Subject: | Class::Unload support for Moose |
Date: | Thu, 8 Jun 2017 07:59:44 +0000 |
To: | "bug-Class-Unload [...] rt.cpan.org" <bug-Class-Unload [...] rt.cpan.org> |
From: | Jose Luis MartÃnez Torres <joseluis.martinez [...] capside.com> |
Hi,
I've ran into a problem in Paws' 01_load.t test case (https://github.com/pplu/aws-sdk-perl/blob/master/t/01_load.t): It tries to load a lot of classes (~8000), and then uses Class::Unload to unload them (they are not necessary during the whole execution of the test, and if left loaded, end up consuming lots of memory). Although I started using Class::Unload some time ago, memory usage is still and issue during the test. I've just realized that Moose stores metainformation about classes in its MOP. Adding remove_metaclass_by_name (https://github.com/pplu/aws-sdk-perl/commit/f530af1140bacb51375d438744893c56208b04d0) has helped solve the issue.
Adding an instruction to tell the MOP to remove the metaclass seems like a nice feature to consider for Class::Unload. I've looked around a bit, and some downstream modules seem to have realized the fact too. The way Class::Refresh does it seems like an elegant way to do it without adding Moose to Class::Unload: https://metacpan.org/source/DOY/Class-Refresh-0.07/lib/Class/Refresh.pm#L129
Would you consider this to be a good feature for Class::Unload?
Best Regards,
Jose Luis Martinez
JLMARTIN on CPAN