Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^8: disable functions if module not installed

by ikegami (Patriarch)
on Nov 04, 2008 at 12:20 UTC ( [id://721365]=note: print w/replies, xml ) Need Help??


in reply to Re^7: disable functions if module not installed
in thread disable functions if module not installed

AUTOLOAD is going into an infinite loop trying to reflect a constant, eating up the entire "C" stack. That's the memory you're running out of.

I'm curious as to what is being autloaded. I'd add a print statement to Image/Magick.pm to print out $constname.

The immediate cause of the problem is probably $! =~ /Invalid/ returning false when it is intended to return true. I'd add a print statement to Image/Magick.pm to print out (0+$!).":$!".

Of course, that's assuming your version of Image::Magick is anything like the latest one. You haven't provided any version info.

By the way,
eval { require Image::Magick };
my $is_Magick = $@ ? 0 : 1;
is simpler and safer when written as
my $is_Magick = eval { require Image::Magick; 1 };

Replies are listed 'Best First'.
Re^9: disable functions if module not installed
by Anonymous Monk on Nov 04, 2008 at 12:43 UTC
    It seems like he didn't install imagemagick correctly (both perl bindings, and library)

      That's would cause bootstrap to die, setting $is_Magick to false. All's good.

      So what's calling AUTOLOAD?

        PerlMagick runs out of memory says It stems from PerlMagick being unable to load libMagick.so: .... Once you figure this out -- by setting LD_LIBRARY_PATH to include the location of libMagick.so.10 or whatever else it takes on your OS -- the "runs out of memory" issue will go away too.

      Hi ikegami and Anonymous Monk,

      ImageMagick-6.4.4-2 and perl 5.10, PerlMagick is installed by the IM installer.

      Everything worked fine with use Image::Magick.

      ikegami , added a print $constname here

      sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant( +) # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; print "\nDEBUG " . $constname . "\n";

      but nothing is printed. If I remove a concatenation point have an operator missing error. Did I put this in the wrong place ?

      And, after a server reboot, the script worked 2 times and then went OOM again !?

      thanks a lot and have a nice day !

      "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://721365]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-19 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found