Math::Prime::Util::MemFree - An auto-free object for Math::Prime::Util


Math::Prime::Util::MemFree - An auto-free object for Math::Prime::Util


Version 0.69


  use Math::Prime::Util;
    my $mf = Math::Prime::Util::MemFree->new;
    # ... do things with Math::Prime::Util ...
  # When the last object leaves scope, prime_memfree is called.


This is a more robust way of making sure any cached memory is freed, as it will be handled by the last MemFree object leaving scope. This means if your routines were inside an eval that died, things will still get cleaned up. If you call another function that uses a MemFree object, the cache will stay in place because you still have an object.



Creates a new auto-free object. This object has no methods and has no data. When it leaves scope it will call prime_memfree, thereby releasing any extra memory that the Math::Prime::Util module may have allocated.

Memory is not freed until the last object goes out of scope. prime_memfree may always be called manually. All memory is freed at END time, so this is mainly for long running programs that want extra control over memory use.


Dana Jacobsen <>


Copyright 2012 by Dana Jacobsen <>

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.