Community
cancel
Showing results for 
Search instead for 
Did you mean: 
stoni
Beginner
73 Views

wrapped memory allocator

Jump to solution
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
0 Kudos
1 Solution
Rob5
New Contributor II
73 Views

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

View solution in original post

5 Replies
Rob5
New Contributor II
73 Views

Christian,

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

Thanks
Rob

stoni
Beginner
73 Views
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
Rob5
New Contributor II
73 Views

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

Rob5
New Contributor II
74 Views

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

View solution in original post

stoni
Beginner
73 Views
Hi Rob,

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

Christian
Reply