https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6514

           Summary: More carefully distinguish between perl clearing and
                    deallocating memory
           Product: Spamassassin
           Version: SVN Trunk (Latest Devel Version)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Libraries
        AssignedTo: [email protected]
        ReportedBy: [email protected]


SpamAssassin is quite memory hungry for various reasons. Its basic premise
is that a complete mail message is available in memory, and often in several
representations. Due to the way Perl allocates/reuses memory, when a
long-running process (such as spamd or amavisd) is processing more than
one message in a row, its memory footprint often grows, and cannot shrink.

It would be difficult to change that approach, but at least we can help
perl's memory management a little when an application knows something
which perl by itself can not.

Here is a most instructive insight into perl memory management,
explaining a distinction between clearing and deallocating memory:

  http://www.perlmonks.org/?node_id=803515

In brief:
  my $a = "abc"; $a = "";    # clears but leaves buffer allocated
  my $a = "abc"; $a = undef; # clears but leaves buffer allocated
  my $a = "abc"; undef $a;   # deallocates buffer
  { my $a = "abc"; ... };    # getting out of scope does not deallocate
and similarly for arrays and hashes:
  my @a = (1,2,3); @a = ();  # clears but leaves array allocated
  my @a = (1,2,3); undef @a; # deallocates array

Whether clearing or deallocating is more appropriate depends on
what is a future expected use of such a variable, and how big it is.
Clearing is fast, deallocating makes memory available for other uses
but burdens memory management more.

I'm opening this ticket just as a general reminder and a placeholder
for comments. I may tweak some detail in this regard when I stumble
across it.

-- 
Configure bugmail: 
https://issues.apache.org/SpamAssassin/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to