Public bug reported: [Impact]
There is a memory leak in python3-sysv-ipc, that is only seen under python3 and not under python2, and the author of the software, Philip Semanchuk, has kindly asked for this to be fixed [1] on the ubuntu-devel-discuss mailing list. [1] https://lists.ubuntu.com/archives/ubuntu-devel- discuss/2026-January/019790.html [Testcase] $ sudo apt install python3-sysv-ipc python3-numpy $ cat >> reproducer.py << EOL import numpy as np import sysv_ipc import resource if __name__ =='__main__': queue = sysv_ipc.SharedMemory(None, flags=sysv_ipc.IPC_CREX, size=128, mode=0o600) try: while True: queue_info = np.array([5000, 64, 0, 0, 0]) #queue_info = b'askdfhkjasdfkasdhfkhfkhflkjhasfhds' queue.write(queue_info) print('Memory usage : %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) finally: queue.remove() EOL $ python3 reproducer.py The memory usage will keep on increasing. There is a test package available in the following ppa: https://launchpad.net/~mruffell/+archive/ubuntu/lp2139394-updates If you install it, the memory usage will be stable and not leak every allocation. [Where problems can occur] Memory is leaked on every numpy allocation and is never freed, and we are now adding a check to see if we are running under a python2 interpreter and if we are to release the memory once we are finished with it. This should be compatible with both python2 and python3 users. In the unlikely event a user is relying on reusing memory, they may find the data is now freed and overwritten instead of being leaked permanently. If a regression were to occur, users may see memory leaks or incorrect computations. [Other info] The upstream bug for this issue is: https://github.com/osvenskan/sysv_ipc/issues/7 This was fixed in version 1.0.1 by: commit 03a4cb02af525369838369a857d0eb857eaf39ae From: osvenskan <[email protected]> Date: Sun, 24 Nov 2019 22:52:14 -0500 Subject: add release of data buffer. Link: https://github.com/osvenskan/sysv_ipc/commit/03a4cb02af525369838369a857d0eb857eaf39ae ** Affects: python-sysv-ipc (Ubuntu) Importance: Undecided Status: Fix Released ** Affects: python-sysv-ipc (Ubuntu Jammy) Importance: Medium Assignee: Matthew Ruffell (mruffell) Status: In Progress ** Also affects: python-sysv-ipc (Ubuntu Jammy) Importance: Undecided Status: New ** Changed in: python-sysv-ipc (Ubuntu) Status: New => Fix Released ** Changed in: python-sysv-ipc (Ubuntu Jammy) Status: New => In Progress ** Changed in: python-sysv-ipc (Ubuntu Jammy) Importance: Undecided => Medium ** Changed in: python-sysv-ipc (Ubuntu Jammy) Assignee: (unassigned) => Matthew Ruffell (mruffell) -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2139394 Title: python3-sysv-ipc leaks memory under python3 To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/python-sysv-ipc/+bug/2139394/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
