Memory consumption concern regarding asynchronous code in Perl

George R. Source

I'm running a Perl web server which needs to do some work asynchronously. For this, I use the threads module in the following way:

threads->create(sub {
  # Asynchronous code here
  threads->exit();
});

I have some concerns regarding the correctness of this. Whenever I exit the server, I get the following message:

Perl exited with active threads:
0 running and unjoined
1 finished and unjoined
0 running and detached

I guess this has to do with the fact that I didn't joined or detached my thread. Detaching my thread would be a good solution but, unfortunately, it triggers this: https://bugzilla.redhat.com/show_bug.cgi?id=548249.

Now, here are my questions. Is there any problem with running the thread without joining or detaching it? Is it going to be a memory leak because of the unjoined/undetached threads? Should I run some cleanup code to take care of the finished threads?

Thank you in advance!

multithreadingperlasynchronousmemory

Answers

comments powered by Disqus