Memory leak
See original GitHub issueSome of the functions seem to leak memory. The test program below will continuously eat up more and more memory.
I suspect the issue is in your use of Py_BuildValue without freeing the char* afterwards. For example, in curvemath_mul, resultX and resultY are allocated but never freed.
#!/usr/bin/env python
import fastecdsa.curvemath, fastecdsa.curve, gc
sx = str(fastecdsa.curve.secp256k1.G[0])
sy = str(fastecdsa.curve.secp256k1.G[1])
sz = str(2**255-1)
while True:
fastecdsa.curvemath.mul(sx, sy, sz, 'secp256k1')
gc.collect()
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Memory leak - Wikipedia
In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in...
Read more >What is Memory Leak? How can we avoid? - GeeksforGeeks
Memory leak occurs when programmers create a memory in heap and forget to delete it. The consequences of memory leak is that it...
Read more >Definition of memory leak - PCMag
When memory is allocated, but not deallocated, a memory leak occurs (the memory has leaked out of the computer). If too many memory...
Read more >Memory Leaks and Garbage Collection | Computerworld
DEFINITION A memory leak is the gradual deterioration of system performance that occurs over time as the result of the fragmentation of a...
Read more >Find a memory leak - Windows drivers - Microsoft Learn
A memory leak occurs when a process allocates memory from the paged or nonpaged pools, but doesn't free the memory.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I gave this a try with current version and secp256k1: signature checks do not leak anymore, but signing does.
Attached patch fixes a number of memory leaks. After applying it, I can run curvemath.mul, curvemath.add and _ecdsa.verify in loops without increasing the memory usage.
memleak.patch.txt
Can you please check & merge?