Skip to content
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 #30

Closed
jeremie-lg opened this issue Aug 24, 2018 · 4 comments
Closed

memory leak #30

jeremie-lg opened this issue Aug 24, 2018 · 4 comments

Comments

@jeremie-lg
Copy link

I try to contruct and destroy a nvdb::VolumeGVDB multiple times. I monitor a memory leak. This simple code illustrates the leak.
while (1) { nvdb::VolumeGVDB gvdb; gvdb.SetCudaDevice(GVDB_DEV_FIRST); gvdb.Initialize(); }
Is there a function to free the VolumeGVDB or is this pattern not permitted in gvdb ?

@ramakarl
Copy link
Contributor

This should work.
Would be interesting to determine the root cause.

@oursnoir
Copy link

oursnoir commented Apr 24, 2019

Hmm, is there any destructor in the VolumeGVDB class that deallocate the following members (allocated in VolumeGVDB::Initialize)?

  • mCudpp (CPU and GPU leak ?)
  • mPlan_max (CPU and GPU leak ?)
  • mPlan_min (CPU and GPU leak ?)
  • mScene (CPU leak ?)
  • mPool (CPU and GPU leak ?)
  • cuVDBInfo (GPU leak only)
  • mTransferPtr (GPU leak only)

These are the ones for which I can't find any deallocation code and that I can (without a 100% certainty) relate to the trace given by a cuda-memcheck --leak-check full invocation.

Additionnaly there is no member method of VolumeGVDB that release the memory allocated by mPool.

I have to do something like (not sure what is absolutely necessary or not though):

gvdb->DestroyChannels();
gvdb->CleanAux();
gvdb->mPool->PoolReleaseAll();
gvdb->Clear();

But it doesn't solve the leak from the above-mentioned members.

@NBickford-NV
Copy link
Collaborator

Hi all,

I finally implemented destructors for most of the main GVDB classes in cpmmits dc4d3a0 and f0d05bb.

This makes it so that
while (1) { nvdb::VolumeGVDB gvdb; gvdb.SetCudaDevice(GVDB_DEV_CURRENT); gvdb.Initialize(); }
should run without leaking memory (testing in gRenderKernel, the amount of memory used appears to be constant). Note that it's important to use GVDB_DEV_CURRENT when creating and destroying GVDB objects in a loop like this - otherwise, each GVDB instance will create a new CUDA context just for that instance, and since GVDB allows user code to pick up on the generated CUDA context, will keep the context around (and consequently accumulate CUDA contexts if run in a loop)!
while (1) { nvdb::VolumeGVDB gvdb; gvdb.SetCudaDevice(GVDB_DEV_FIRST); gvdb.Initialize(); }

In addition, cuda-memcheck --leak-check full should now run cleanly (with the exception of a CUDA/OpenGL interop error) on the three non-interactive samples.

Please let me know if this significantly breaks things, since it also slightly changes the semantics of setting the scene's camera and light objects (these functions now own the pointers that you pass to them), and could cause problems with applications that shared pointers to the same object across multiple volumes.

Hope this helps!

@NBickford-NV
Copy link
Collaborator

Closing, since this seems to have been fixed by the commit described in the last post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants