Can't run kernel more than once when passing array from C#

Above is the code I’m working on. From the left:

  1. .NET code using DllImport to invoke the C++ function. Tried different calling conventions already.
  2. C++ function called.
  3. A big part of the computeNormalsAndFilter function.

During the lifetime of an app, I would like to call the C++ function multiple times. The second time I do it, I get error 1 from computeAndFilter kernel (invalid attributes). The code works just fine if I don’t run cudaFree(); but my gut feeling says it should be there.

Please don’t post pictures of code on this forum.

It should be possible to identify the source of the error, but I won’t be able to help further if you only want to provide a subset of the code. I don’t know which line of code is reporting that error, putting ellipsis … instead of your actual code and actual error handling code is not helpful.