0

I wrote some C code to create a python module. I wrote the code myself (did not use SWIG etc). If you're interested, the C code is at the bottom of this thread.

Q: Is there any way to (hopefully, easily) find whether my C code has memory leaks? Is there any way to use python's awesomeness for finding memory leaks in its extensions?

3
  • If on Linux -> valgrind Commented Jan 12, 2015 at 16:41
  • 1
    sys.getrefcount(some_object) can be helpful for quick sanity checks (e.g. making sure that you don't accidentally increase the refcount of an input object to your function unexpectedly) -- But it isn't a substitute for a leak detecting tool like valgrind. Commented Jan 12, 2015 at 16:48
  • Similar question which is answered. stackoverflow.com/questions/3982036/… Commented Jul 23, 2018 at 9:54

1 Answer 1

1

if you using a linux environment we can easily find the memory leaks by using debugger named valgrind. To get the valgrind first you have to install it from the internet by using command

sudo apt-get valgrind

after the installation is completed compile your c code using this debugger you can easily find the memory leaks. This debugger shows what is the reason for the memory leak and also specifies the line at which the leak has been occured.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.