Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Overriding malloc()

Hi all,

I am in the process of integrating OpenCV into a large code base (100K+ lines). To track and control memory usage, I'd like to override all memory allocation and deallocations by OpenCV. I understand that I can override the new [] operator to partly achieve this goal.

However, OpenCV source also relies on malloc() calls. My research shows me that the easiest way to override malloc() calls is to use pre-processor macros like the one below since there is no portable way of overriding malloc (e.g., malloc hooks only work in Linux).

define malloc(X) my_malloc((X))

However, the macro option obviously will not work for pre-compiled binaries. My question is this: does OpenCV use any pre-built binaries that may be calling malloc()?

Thank you, Fijoy