title: Tips for keeping Perl memory usage low
body: <p>What are some good tips for keeping memory usage low in a Perl script? I am interested in learning how to keep my memory footprint as low as possible for systems depending on Perl programs. I know Perl isn't great when it comes to memory usage, but I'd like to know if there are any tips for improving it.</p>
  
  <p>So, what can you do to keep a Perl script using less memory. I'm interested in any suggestions, whether they are actual tips for writing code, or tips for how to compile Perl differently.</p>
  
  <p><strong>Edit for Bounty:</strong>
  I have a perl program that serves as a server for a network application. Each client that connects to it gets it's own child process currently. I've used threads instead of forks as well, but I haven't been able to determine if using threads instead of forks is actually more memory efficient.</p>
  
  <p>I'd like to try using threads instead of forks again. I believe in theory it should save on memory usage. I have a few questions in that regard:</p>
  
  <ol>
  <li>Do threads created in Perl prevent copying Perl module libraries
  into memory for each thread?</li>
  <li>Is <a href="http://search.cpan.org/~jdhedden/threads-1.86/lib/threads.pm">threads</a> (use threads) the most efficient way (or the only)
  way to create threads in Perl?</li>
  <li>In threads, I can specify a stack_size paramater, what specifically
  should I consider when specifying this value, and how does it impact
  memory usage?</li>
  </ol>
  
  <p>With threads in Perl/Linux, what is the most reliable method to determine the actual memory usage on a per-thread basis?</p>