CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Post deleted by sonal

 



sabby
New User

Dec 8, 2015, 2:59 AM

Post #1 of 5 (6340 views)
Post deleted by sonal

 


BillKSmith
Veteran

Dec 8, 2015, 6:29 AM

Post #2 of 5 (6332 views)
Re: [sonal] Memory leak with Autoload method [In reply to] Can't Post

I really do not understand your problem, but I can offer a few suggestions.

Post an example that we can run and duplicate your problem. Explain what you expect and what actually does happen.

AUTOLOAD is a rather advanced feature of perl. If you are truly new to perl, you probably should postpone your use of this feature until you are more familiar with the basics.

AUTOLOAD is intended to be the default method in object oriented perl. It seems you are trying to use it as an ordinary function. I am not sure what you expect to happen.

An undefined method in AUTOLOAD would cause AUTOLOAD to recurse on itself infinitely. It probably does the same with any undefined function. This may be what you mean by "memory leak".
Good Luck,
Bill


sabby
New User

Dec 8, 2015, 7:56 AM

Post #3 of 5 (6325 views)
Post deleted by sabby [In reply to]

 


FishMonger
Veteran / Moderator

Dec 8, 2015, 8:21 AM

Post #4 of 5 (6322 views)
Re: [sonal] Memory leak with Autoload method [In reply to] Can't Post


Quote
I was actually writing a Universal::Autoload in my script

Why? What are you really wanting to accomplish?

If you want help, you'll need to post a short but complete script that demonstrates the problem and make sure it includes the strict and warnings pragmas.

I agree with Bill. Since you're new to perl, you should avoid playing around with Autoload until you learn more about perl. Even experienced perl programmers rarely, if ever, do anything with Autoload.


BillKSmith
Veteran

Dec 8, 2015, 12:21 PM

Post #5 of 5 (6313 views)
Re: [sonal] Memory leak with Autoload method [In reply to] Can't Post

I copied your code onto my computer and ran it. That confirmed my previous description. There is no mysterious "module". Given that AUTOLOAD runs whenever a function cannot be found, your code contains an explicit recursion of infinite depth.

Your main program calls undefined_function. AUTOLOAD runs instead. It never completes because it prints its message and then calls undefined_function (AUTOLOAD) which never completes because it prints its message and then calls ...

This continues until you manually interrupt the program.

We cannot help you to fix this because we have no idea what you are trying to do. As Fishmonger suggested, If you explain what you want to accomplish, we probably can offer a solution which does not require recursion or AUTOLOAD.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives