Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nasty memory leak in FAST_SEQ_UNSAFE macro #293

Closed
sagetrac-dmharvey mannequin opened this issue Feb 24, 2007 · 3 comments
Closed

nasty memory leak in FAST_SEQ_UNSAFE macro #293

sagetrac-dmharvey mannequin opened this issue Feb 24, 2007 · 3 comments

Comments

@sagetrac-dmharvey
Copy link
Mannequin

sagetrac-dmharvey mannequin commented Feb 24, 2007

It appears that FAST_SEQ_UNSAFE creates a new reference to the list but never releases it.

It might be because PySequence_Fast returns a new reference, but PySequence_Fast_ITEMS doesn't release it.

See also

http://docs.python.org/api/sequence.html

CC: @sagetrac-dmharvey

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/293

@williamstein williamstein added this to the sage-2.8.2 milestone Aug 18, 2007
@robertwb
Copy link
Contributor

comment:2

Replying to @williamstein:

Now that we have fast list indexing, there should be very few instances where we need to use this macro...

@williamstein
Copy link
Contributor

comment:3

Confirmed. This is a major memory leak

[18:35] <william> indeed!
[18:35] <william> david harvey is totally right about that memory leak!
[18:35] <william> Try the following two distinct blocks of code, where m = get_memory_usage
[18:35] <william> print m()
[18:35] <william> n = random_matrix(RR, 200) 
[18:35] <william> n.set_immutable()
[18:35] <william> hash(n)
[18:35] <william> del n
[18:35] <william> m()
[18:35] <william>   -- and --
[18:35] <william> print m()
[18:35] <william> n = random_matrix(RR, 200) 
[18:35] <william> n.set_immutable()
[18:35] <william> del n
[18:35] <william> m()
[18:36] <william> The first leaks about 3MB every time.  The second doesn't leak at all.
[18:36] <robertwb> ouch
[18:36] <robertwb> yes, it's a new reference (though it may or may not be a new object)


print m()
n = random_matrix(RR, 200) 
n.set_immutable()
hash(n)
del n
m()

@robertwb
Copy link
Contributor

Attachment: no-FAST_SEQ_UNSAFE.patch.gz

patch to remove all uses of FAST_SEQ_UNSAFE

tobiasdiez pushed a commit to tobiasdiez/sage that referenced this issue Feb 22, 2024
Source shall be url and not path.
path is only for directories.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants