You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@issues.apache.org on 2010/11/16 17:28:04 UTC

[Bug 6514] New: More carefully distinguish between perl clearing and deallocating memory

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: dev@spamassassin.apache.org
        ReportedBy: Mark.Martinec@ijs.si


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.

[Bug 6514] More carefully distinguish between perl clearing and deallocating memory

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6514

Michael Parker <pa...@pobox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |parkerm@pobox.com

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

[Bug 6514] More carefully distinguish between perl clearing and deallocating memory

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6514

Mark Martinec <Ma...@ijs.si> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|Undefined                   |3.4.0

--- Comment #3 from Mark Martinec <Ma...@ijs.si> 2010-11-30 14:16:07 UTC ---
> Wasn't this closely related to the circular references that are used in the
> SpamAssassin libraries? There was a discussion about using weaken() in bug
> 6514.

No, it is unrelated. The only commonality is a term 'memory'.

Closing, this bug only serves as a documentation placeholder.

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

[Bug 6514] More carefully distinguish between perl clearing and deallocating memory

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6514

--- Comment #1 from Mark Martinec <Ma...@ijs.si> 2010-11-16 11:31:19 UTC ---
Here is one such easy case:

"Bug 6514, minor detail"
  Sending lib/Mail/SpamAssassin/Message.pm
Committed revision 1035678.

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

[Bug 6514] More carefully distinguish between perl clearing and deallocating memory

Posted by bu...@issues.apache.org.
https://issues.apache.org/SpamAssassin/show_bug.cgi?id=6514

Daniel Lemke <le...@jam-software.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lemke@jam-software.com

--- Comment #2 from Daniel Lemke <le...@jam-software.com> 2010-11-19 03:05:04 UTC ---
Wasn't this closely related to the circular references that are used in the
SpamAssassin libraries? There was a discussion about using weaken() in bug
6514.

Daniel

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