-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak #746
Comments
Hi, this issue is currently the major showstopper for my application, so I did some investigating. It turns out that the culprit is not sort() but exclusive_scan() which is called by boost::compute's radix sort implementation. In other words, replace your sort() calls with calls to exclusive_scan() and you will see the same behavior. I could further trace the problem to detail::scan_impl(). Curiously, the problem does not affect inclusive_scan, which also makes use of scan_impl(), and scan_impl() also works fine if the exclusive boolean parameter is set to false. The weird thing is that scan_impl() itself doesn't even seem to depend on the exclusive boolean parameter, it is simply forwarded to local_scan_kernel. However, as a meta kernel object, local_scan_kernel just builds kernel source code which is slightly different if exclusive==true. How could this leak memory? Or am I on the wrong track? I'm not very familiar with internals of boost::compute, so it could well be that I've missed something. Update: I've found that if I change the line 113 in scan_on_gpu.hpp (this is in the local_scan_kernel) from |
It is indeed the combination of "if(lid == block_size - 1){\n" <<
" " << decl<T>("temp") << " = " << first[expr<cl_uint>("gid")] <<";\n"<<
" block_sums[get_group_id(0)] = " <<''
op(var<T>("temp"), var<T>("scratch[lid]")) <<
";\n" <<
"}\n"; gets rid of the memory leak. This could be a possible workaround until the root cause is found. |
The compute::reduce() function also leaks (except if the binary function is compute::plus<> )
The two reference count should be equal.
IMHO the
leaves the extra buffer reference. |
@jszuppe Hi. I used exclusive_scan and reduce function. My program is also faced with memory leak. Could you check and modify the code ? |
~buffer_iterator_index_expr()
{
// set buffer to null so that its reference count will
// not be decremented when its destructor is called
m_buffer.get() = 0;
}
It should not leave extra buffer reference since in the constructor: buffer_iterator_index_expr(const buffer &buffer,
size_t index,
const memory_object::address_space address_space,
const IndexExpr &expr)
: m_buffer(buffer.get(), false),
... it does not increase the reference counter of buffer. However, I'll check it. |
It seems that default copy ctor is causing this problem. I'll check if that [adding it] fixes the problem in other reported cases. |
It seems that it fixes all reported issues reported in this thread. |
Should be fixed by #780. Reopen if you still get this problem on |
Thanks. Seems memory leak issue solved. |
Hello,
I have found that using sort or sort_by_key command multiple times i get memory leak (memory usage is growing). In follow example i get the memory leak, if i just comment the line "boost::compute::sort" memory leak disappears. Why that happening? Maybe i doing something wrong?
The text was updated successfully, but these errors were encountered: