Hello Cython devs,
I am working on a project where we have a main C++ application that embeds a python interpreter and makes calls into cython/python code.
Primary Question:
Essentially we instantiate a large struct on the heap in C++ that contains a vector of ints and pass that struct by pointer into cython where calculations are done. The vector of ints needs to be resized before I can assign the results from cython via memoryviews.
Is that illegal in terms of memory management? Am I allowed to call std::vector.resize() in that context from cython? Is the memory ownership somehow changing when the vector gets reallocated?
Note: in that github repo I posted with the example code, I can't the "mismatched free" I was seeing in valgrind (on my work computer) to show up, but in our original project we had a "mismatched free" that pointed exactly to the "vector.resize()" call. Hopefully the code is still useful to you for understanding the context of the code I'm analyzing.
Secondary Question:
Does anyone have a preferred method for debugging memory leaks for cython/python embedded in C++ ? Currently I'm using valgrind with the python suppressions file, but we also use gperftools on our C++ apps and I'd prefer to use that if possible on the cython also. (Tried compiling my cython extensions with -ltcmalloc and recompiling the python interpreter, but it still seemed like it gave garbage output).
Thank you so much for reading this! Any help is appreciated.
Richard