wrapped memory allocator

wrapped memory allocator

Hi all,

I'm evaluating the Intel C++ Studio for Linux. Yesterday I was trying the Inspector XE on my software. In my software I have wrapped the calls to malloc/free in order to be flexible in the future (tcmalloc/jemalloc).

Now all the memory-leaks that show-up after the analysis show as leaks in my wrapper code, which makes it impossible to see which function doesn't free its allocated memory.

Is there a possibility to show the whole call-stack in case of a memory-leak?

Many thanks for your help!
Christian

6 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Christian,

Can you provide a usage
example / reproducer that can be compiled to test with?

Thanks
Rob

Hi Rob,

I can quickly outline in "pseudo-code":

Lets say I have the following wrappers

size_t zmalloc(size_t howmuch) {
return(malloc(howmuch));
}

void zfree(size_t adr) {
return(free(adr));
}

I do this so that I could replace malloc and free with some other allocaters later if required.. like tcmalloc... however that doesn't mean that it is a memory leak its only if the code that uses it doesn't handle it properly.

Now I have some custom module

void newFoo(foo** f) {
*f = (foo*)zmalloc(sizeof(foo));
*f->bar = 324.35;
}

void freeFoo(foo** f) {
zfree(*f);
*f = NULL;
}

As a last step I have a main function:

int main(....) {
foo* f;

newFoo(&f);

// memory leak

return(0);

}

Now what I would expect in the report is not just the pointer to the code in the wrapper but rather, bubbling up the whole call-stack and report newFoo(&f) in the main() method as the root-cause of the leak..

Valgrind can do this in Linux without problems.. so I'm wondering whether Inspector could be configured to do so as well?

Thanks,
Christian

Christian,

Can you let me know if you
are using the GUI to review the results or are you reviewing the results via
command line reporting? If you are using
the GUI, when you click into an error, the stack is displayed to the
right. Make sure that you have the stack
frame depth set to sufficient level. If
you are using the command line only, let me know.

Thanks
Rob

Best Reply

Christian,

Thank you for the detail about your configuration and
the screenshots. In the screenshot (Screenshot-1.png),
if you double-click on the reported error, you should be able to drill into the
detail for the error. Typically, the
stack is displayed in the far right panel. Let me know what you find.

- Rob

Hi Rob,

Thanks for the hint, afterall it seems that it was quite a stupid question... sorry about that.

Christian

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen