Paolo88

Memory leaks during clGetPlatformIDs call

Discussion created by Paolo88 on Jul 10, 2010
Latest reply on Jul 29, 2010 by omkaranathan
found a memory leak. Is it my fault?

Hi to everyone.

I'm here because I'm having some proble with my code.

I'm running my code over a Linux Ubuntu 9.04 with OpenCL SDK 2.01.

The problem is that I found some memory leaks when I do the call clGetPlatformIDs.

 

Here is a working example:#include
#include


using namespace std;

 

int main(){

cl_platform_id id;
cl_uint numberOfPlatform;

cl_int err = clGetPlatformIDs(1, &id, &numberOfPlatform);

if(err != CL_SUCCESS){
cout << "Error!!!" << endl;
}

cout << "Found: "
<< numberOfPlatform
<< " platforms."
<< endl;

return 0;
}

 

The output is:

Found: 1 platforms.

 

but if I run this code with valgrind I found 3699 bytes totally lost!!!

 

valgrind ./a.out
==4918== Memcheck, a memory error detector
==4918== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==4918== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==4918== Command: ./a.out
==4918==
Found: 1 platforms.
==4918==
==4918== HEAP SUMMARY:
==4918== in use at exit: 15,669 bytes in 173 blocks
==4918== total heap usage: 2,044 allocs, 1,871 frees, 1,454,721 bytes allocated
==4918==
==4918== LEAK SUMMARY:
==4918== definitely lost: 3,699 bytes in 10 blocks
==4918== indirectly lost: 0 bytes in 0 blocks
==4918== possibly lost: 403 bytes in 2 blocks
==4918== still reachable: 11,567 bytes in 161 blocks
==4918== suppressed: 0 bytes in 0 blocks
==4918== Rerun with --leak-check=full to see details of leaked memory
==4918==
==4918== For counts of detected and suppressed errors, rerun with: -v
==4918== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 77 from 15)

 

Has anyone encountered this situation before?

Is it my fault or what?

On the OpenCL specification I didn't see any kind of "clReleasePlatform" or something like that.

I would like to know your opinion about this issue.

 

Thanks in advance to anyone.

 

Paolo

#include <iostream> #include <CL/cl.h> using namespace std; int main(){ cl_platform_id id; cl_uint numberOfPlatform; cl_int err = clGetPlatformIDs(1, &id, &numberOfPlatform); if(err != CL_SUCCESS){ cout << "Error!!!" << endl; } cout << "Found: " << numberOfPlatform << " platforms." << endl; return 0; }

Outcomes