On Mon, Jul 20, 2015 at 5:13 PM, Kent Fredric <[email protected]> wrote:

> On 21 July 2015 at 03:35, Rick Leir <[email protected]> wrote:
> > My question is how can you delete all the images but retain the
> > Graphics::Magick object? I do not want to use the undef loop above. With
> > normal perlmagick, you would say
> >   @$image = ();
> > ( http://www.graphicsmagick.org/perl.html )
> >
> > Should I learn more about Perl XS?  TIA
>
>
> Q) What value is there in persisting the GM object across uses? Why do
> you need to do this?
>
This is for a web service, so I want to reduce latency by keeping the GM
object. We get at it using 'instance', not 'new'. And reclaiming image
memory is important.


>
> Without good reason, I would take the advice in the Linked article,
> and just `undef` the GM object.
>
> The natural way of doing this in Moo would be to use a clearer
>
> https://metacpan.org/pod/Moo#has
>
> #{
>
> Takes a method name which will clear the attribute.
>
> If you set this to just 1, the clearer is automatically named
> clear_${attr_name} if your attribute's name does not start with an
> underscore, or _clear_${attr_name_without_the_underscore} if it does.
> This feature comes from MooseX::AttributeShortcuts.
>
> #}
>
> That way, when you're done, you just call
>
>  $self->_clear_image;
>
> And if you need an image later, a new one will be constructed by the
> builder.
>
Thanks for explaining 'clearer'.
cheers -- Rick

>
> --
> Kent
>
> KENTNL - https://metacpan.org/author/KENTNL
>



-- 
Rick Leir
Developer, Canadiana.ca

Reply via email to