Issue 3712: memoryview leaks references
Created on 2008-08-28 11:00 by amaury.forgeotdarc, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| memleak.patch | pitrou, 2008-08-28 11:23 | |||
| memleak2.patch | pitrou, 2008-08-28 12:37 | |||
| Messages (6) | |||
|---|---|---|---|
| msg72078 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * ![]() |
Date: 2008-08-28 11:00 | |
Two problems with memoryview:
- The buffer interface of memoryview leaks a reference:
str(memoryview(b'text'), 'utf-8')
- memoryview does not implement tp_traverse and tp_clear, so reference
cycle cannot be collected, as with:
import gc
class MyBuf(bytes): pass
def f():
buf = MyBuf(b'abc')
m = memoryview(buf)
buf.m = m
gc.collect();gc.collect();gc.collect()
each call to f() leaks 6 references.
|
|||
| msg72080 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2008-08-28 11:23 | |
Here is a patch. I feel a bit unsafe with the intended semantics of getting a buffer on a memoryview object, but it fixes the leak. |
|||
| msg72082 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2008-08-28 11:25 | |
(I forgot to say, the patch is for the first problem only) |
|||
| msg72086 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2008-08-28 12:37 | |
Here is an aggregate patch addressing both problems. Please review. |
|||
| msg72243 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2008-09-01 13:59 | |
I think the patch looks good. |
|||
| msg72261 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2008-09-01 15:10 | |
Fixed in r66111. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:38 | admin | set | github: 47962 |
| 2008-09-01 15:10:59 | pitrou | set | status: open -> closed resolution: fixed messages: + msg72261 |
| 2008-09-01 14:20:19 | benjamin.peterson | set | keywords: - needs review |
| 2008-09-01 13:59:17 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg72243 |
| 2008-08-28 12:37:16 | pitrou | set | files:
+ memleak2.patch messages: + msg72086 |
| 2008-08-28 11:25:41 | pitrou | set | messages: + msg72082 |
| 2008-08-28 11:23:32 | pitrou | set | files:
+ memleak.patch nosy: + pitrou, teoliphant messages: + msg72080 components: + Interpreter Core keywords: + patch, needs review type: resource usage |
| 2008-08-28 11:00:03 | amaury.forgeotdarc | create | |
