Is this a memory leak?

34 views
Skip to first unread message

Husain Al Marzooq

unread,
May 18, 2024, 1:32:58 PMMay 18
to cython-users
I made this library recently. The thing is, when I create multiple instances of the class/extension type:

import anycrc

for i in range(1000000):
    anycrc.Model('CRC32')

I'm seeing the memory usage increase by about 300k-400k every second in the task manager.

This could be a problem with something else, but it's worth asking if this is caused by the generated Cython code?

da-woods

unread,
May 19, 2024, 3:44:35 AMMay 19
to cython...@googlegroups.com
It does sound like a memory leak. It's not impossible that it's a bug in Cython but I'd say it's more likely to be in your code or the library you're wrapping. You could try a tool like Valgrind (but you'll get a lot of false positives from Python I think). Or you could start removing chunks of your code and see if you can pinpoint the culprit.

I'd recommending you use `__cinit__` and `__dealloc__` instead of `__init__` and `__del__` for the bits of your code that deal with memory management. They have the advantage that they're guaranteed to be called exactly once (which `__init__` and `__del__` may be skipped or called multiple times in some cases).
--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cython-users/358a3b6a-b98f-4b90-b67c-0f786f546e1bn%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages