Opened 14 years ago

Closed 14 years ago

#4241 closed defect (fixed)

[with patch; positive review] magma -- memory is never freed in the interface when MagmaElement's are deleted

Reported by: William Stein Owned by: William Stein
Priority: major Milestone: sage-3.2
Component: interfaces Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Observe:

sage: a = magma('10000')
sage: a.name()
'_sage_[1]'
sage: del a
sage: magma.eval('_sage_[1]')
'10000'

Whenever anybody ever creates a MagmaElement? via the Magma interface, it doesn't get deleted. This is because possible (1) the clear method in magma.py is commented out, and/or (2) the _available_var list that gets appended to in (1) isn't actually used by magma.py, so e.g., _sage_[1] in the example above never gets re-used.

Attachments (1)

sage-4241.patch (2.8 KB) - added by William Stein 14 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 14 years ago by William Stein

Status: newassigned

comment:2 Changed 14 years ago by William Stein

Here's a vivid illustration of the memory leakage, which of course we know is there by reading the code:

sage: a = [magma('3^100000') for _ in range(1000)]
sage: magma.GetMemoryUsage()
42917912
sage: del a
sage: magma.GetMemoryUsage()
42917912
sage: a = [magma('3^100000') for _ in range(1000)]
sage: magma.GetMemoryUsage()
69103640
sage: del a
sage: magma.GetMemoryUsage()
69103640

comment:3 Changed 14 years ago by William Stein

Without patch:

sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage() 
42917912
sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage() 
94192176
sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage()
121287216

With patch:

sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage()
40817200
sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage()
41820720
sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage()
41820720
sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage()
41820720
sage: a = [magma('3^100000') for _ in range(1000)]; del a;magma.GetMemoryUsage()
41820720

}}}

Changed 14 years ago by William Stein

Attachment: sage-4241.patch added

comment:4 Changed 14 years ago by William Stein

Summary: magma -- memory is never freed in the interface when MagmaElement's are deleted[with patch; needs review] magma -- memory is never freed in the interface when MagmaElement's are deleted

comment:5 Changed 14 years ago by Michael Abshoff

Summary: [with patch; needs review] magma -- memory is never freed in the interface when MagmaElement's are deleted[with patch; positive review] magma -- memory is never freed in the interface when MagmaElement's are deleted

Patch looks good to me. There is a spelling error in the new docstring: "clearlying" _ i will fix it in the patch I will apply.

Cheers,

Michael

comment:6 Changed 14 years ago by Michael Abshoff

Milestone: sage-3.2.1sage-3.2
Resolution: fixed
Status: assignedclosed

Merged in Sage 3.2.alpha1

Note: See TracTickets for help on using tickets.