Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: How to reduce memory by killing redundant perl executables

by Abigail (Deacon)
on Jul 13, 2001 at 17:30 UTC ( #96387=note: print w/replies, xml ) Need Help??

in reply to How to reduce memory by killing redundant perl executables

If this is the code you are actually using, then I will assume there is a problem with the program (assuming you want the program to survive its parent). See, if you do a system, Perl will launch the program you gave it as an argument and then wait for the launched program to complete before continuing with the next statement. Hence, by the time it gets to the exit, the launced program has terminated.

This however doesn't seem to match your description. Your description however of what you have and what you want are too confusing for me, and I don't understand what your goals are.

-- Abigail

Replies are listed 'Best First'.
Re: Re: How to reduce memory by killing redundant perl executables
by baku (Scribe) on Jul 13, 2001 at 18:07 UTC

    Abigail seems to have hit the nail on the head; the "excess" perl processes you're seeing are the parents of all the child processes created by system.

    As suggested, think about exec

Re: Re: How to reduce memory by killing redundant perl executables
by juo (Curate) on Jul 13, 2001 at 18:56 UTC

    I am running Perl from an non-Perl application which you can call the parent script. From that script I launch a child script. The application is locked as long as my child script is running. As long as the child script is running the script interact with the parent script. When I run from the child script another child script I cannot use exec because then I also loose the interaction with my parent script. So I only want to kill my child script without loosing the link with my parent. When I use system it's all working fine but it builds up a lot of Perl.exe (windows2000) into the memory without releasing them.

      Let me recap and see if I understand you right.

      You have a non-Perl application, which we will call the "parent". From "parent", you call a Perl program, which we will call "A". From "A", you call another process, called "child". From "child", you call yet another process, which we call "grand child".

      Now, "child" communicates with "parent". But now I am getting confused. You say that you do not want to lose the communication between "child" and "parent", however, you also want to kill "child". So, I am not certain which one you want to get rid of.

      You also say you lose the communication if you exec "grand child", which isn't strange because an exec replaces the current process, it being "child". So, you use system and that works fine, but it leaves running processes behind. Well, of course that "works fine". Now you are not getting rid of "child", just as I said in my previous post. Because you are doing system, "child" will wait till "grand child" is finished before executing the next statement, which happens to be the exit. So.... "child" doesn't go away until "grand child" is finished. But isn't that exactly what you want? Because if "child" goes away your communication is broken anyway....

      -- Abigail

      Let me see if I understand this:
      1. You have an application that isn't Perl.
      2. You run from this application some Perl script.
      3. From the Perl script, you launch another Perl script.
      4. The parent and child scripts talk to one another.
      5. At some point, you wish to be able to launch a grandchild script.
      6. This grandchild script may or may not need to be able to talk to the child script.
      *blinks* I'm going to say right now that this is starting to sound like a poorly-designed application. Without seeing your code, I'm going to bet that you are calling the grandchild script when you probably should have it as a module that you use in the child script. I'm guessing that you have these grandchildren scripts to add functionality, depending on a series of possible outcomes.

      It sounds like you may need to explore modules and redesign the way you're doing things.

      (Please note that you have given very little information about what you're doing and how it's implemented. If you know about modules and are using them, then I apologize for any insult you may feel I have given you.)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2021-04-14 22:24 GMT
Find Nodes?
    Voting Booth?

    No recent polls found