Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Win32::Daemon memory leak

by Athanasius (Archbishop)
on Dec 23, 2015 at 02:55 UTC ( #1150989=note: print w/replies, xml ) Need Help??


in reply to win32::daemon memory leak

Hello tbsky,

Can you give example code for a service you run, together with the command sequence you issue to control service installation, etc.? So far, I’ve not been able to get your code to work — but that’s likely because I don’t know enough about the Win32::Daemon module. :-(

In the meantime, perhaps you could try a module such as Test::LeakTrace. Here’s how I would proceed:

  • Wrap the top-level code into its own subroutine, say sub main
  • Change each exit statement into a return statement; for example, exit 1; becomes return 1;
  • Add the following at the top level:
    use Test::LeakTrace; { my $result; leaktrace { $result = main(); }; exit $result; }
  • Redirect program output to a log file, to facilitate analysis of the leak reports after the service has been stopped and uninstalled.

BTW, the following isn’t very informative:

print "Failed to install service: $!\n";

From the documentation, the correct way to report failure is like this:

print 'Failed to install service: ', Win32::FormatMessage(Win32::Daemon::GetLastError()), "\n";

Also, you have use Fcntl;, but I don’t think it’s actually used anywhere, is it?

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Win32::Daemon memory leak
by tbsky (Novice) on Dec 23, 2015 at 08:13 UTC
    hi:

    sorry the code is not clean. I have modify it. to run it please use the procedure below:

    1. use "memory-leak.pl -i" to install the "memory-leak" service to windows.

    2. use windows gui to start the service or use command "net start memory-leak" to start the service.

    3. use windows gui to watch the "perl.exe" process memory status.

    4. after testing. use windows gui to stop the service or use command "net stop memory leak" to stop the service.

    5. use "memory-leak.pl -r" to remove the service.

      I'm interested in the matter (abandoned services in Perl since the day of "service could not start in a timely fashion".. error)
      I have installed your service and now i'm monitoring it for the next 4 hours, with:
      #PID perl -E "for(1..240){system qq(tasklist /fi \"PID eq 17360\" /n +h);sleep 60}" # UPDATE: RESULTS perl.exe 17360 Services 0 + 9.136 K # 240x60 sec after.. perl.exe 17360 Services 0 + 16.768 K #it leaked 31.8K every minute

      UPDATE: The increment seems to me constant over time even if not so regular: The leak even if little is yet noticeable: the working set is passed fro 9.136K to 9.848K in 15 minutes. Private bytes also are arising. I'm using also Process Explorer. I think you need to investigate further. Have you some holidays? look at this article: identifying-memory-leak-with-process-explorer-and-windbg and share your results! in the meantime I have not enough time to investigate.
      I'll tell you more

      L*
      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
        thanks for the hint. I will spent my time to read your suggestion!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2023-12-09 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (38 votes). Check out past polls.

    Notices?