The problem is that finalizers are executed on the GC thread, CUDA resource allocated in one thread can't be used in another one. A snip from CUDA programming guide:
Several host threads can execute device code on the same device, but by design, a host thread can execute device code on only one device. As a consequence, multiple host threads are required to execute device code on multiple devices. Also, any CUDA resources created through the runtime in one host thread cannot be used by the runtime from another host thread.
Your best bet is to use the using
statement, which ensures that the Dispose()
method gets always called at the end of the 'protected' code block:
using(CudaEntity ent = new CudaEntity())
{
}
arul
2009-09-19 23:52:04