- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all:
Is there any simple way to detect memory leak when using Ipp? I mean I can detect usual leak caused by malloc or new using "_CrtDumpMemoryLeaks()" in VS. But it seems that the memory leaks by ipp*malloc* were not found.
Is there any simple way to detect memory leak when using Ipp? I mean I can detect usual leak caused by malloc or new using "_CrtDumpMemoryLeaks()" in VS. But it seems that the memory leaks by ipp*malloc* were not found.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After trying some times I came to a clumsy solution. However it works:
I replaced the ippimalloc and ippifree with self-defined function like the following.
Somewhere it is stated that all the ipp functions work with normally allocated memory. Then with microsoft built-in memory-leak detection all the leaks can be detected.
#ifdef _DEBUG
#define ippiMalloc_32f_C1(i,j,step) db_ippiMalloc_32f_C1(i,j,step)
#define ippiFree(ptr) db_ippiFree(ptr);
#endif _DEBUG
....
Ipp32f *db_ippiMalloc_32f_C1(int i,int j,int *step)
{
*step=i*sizeof(float);
return (Ipp32f *)malloc(j*(*step));
}
....
void db_ippiFree(void *ptr)
{
free(ptr);
}
....
I replaced the ippimalloc and ippifree with self-defined function like the following.
Somewhere it is stated that all the ipp functions work with normally allocated memory. Then with microsoft built-in memory-leak detection all the leaks can be detected.
#ifdef _DEBUG
#define ippiMalloc_32f_C1(i,j,step) db_ippiMalloc_32f_C1(i,j,step)
#define ippiFree(ptr) db_ippiFree(ptr);
#endif _DEBUG
....
Ipp32f *db_ippiMalloc_32f_C1(int i,int j,int *step)
{
*step=i*sizeof(float);
return (Ipp32f *)malloc(j*(*step));
}
....
void db_ippiFree(void *ptr)
{
free(ptr);
}
....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
you are absolutely correct, IPP functions must work with externally allocated memory (the only drawback here is some reduce in performance, because of unaligned memory access, but it is acceptable for debug build).
Thank you for sharing your trick here
Regards,
Vladimir

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page