Required lifetime of Texture Objects

I’m converting some older CUDA driver API code to use the new CUDA 5.0 / compute cap 3.0 texture objects. I just got something like this working

texobj = cuTexObjectCreate(…)
cuLaunchGridAsync kernel with texobj as parameter
cuTexObjectDestroy(texobj)

This seems to work, but I’m not convinced that what I’m doing is safe. When launching the kernel asynchronously, how do I know that the texture object is not destroyed before it’s used?

I expected the code above to fail, but it doesn’t. In fact, even this seems to work:

texobj = cuTexObjectCreate(…)
cuTexObjectDestroy(texobj)
cuLaunchGridAsync kernel with texobj as parameter

At what point is it safe to delete a texture object being used by an asynchronously launched kernel?

/Lars