NVIDIAGameWorks / FleX

Other
650 stars 100 forks source link

Possible memory leak - allocating soft bodies to assets #79

Open henryclever opened 5 years ago

henryclever commented 5 years ago

I believe there to be a memory leak issue with creating assets and allocating a particlized NvFlexExtCreateSoftFromMesh to the asset. However, with my code set up in the way it is, I can only provide evidence for this memory leak for the following case:

As a global variable, I create the asset during initialization: NvFlexExtAsset* asset; For each rollout (Every 10 seconds or so), I then re-allocate this same asset with a soft mesh using the following: asset = NvFlexExtCreateSoftFromMesh( ....... );

When all rollouts are complete, I destroy the asset. Note that a rollout is not necessarily a single initialization of a scene but rather a set of them (I think this difference is moot for my point though). If instead of running asset = NvFlexExtCreateSoftFromMesh( ....... ); each rollout, I only create the soft the very first rollout, save it, and use it on all subsequent rollouts, there is no leak.

To better confirm this possible leak, I would test the following instead, where a new asset is created and destroyed each rollout: Every 10 seconds: NvFlexExtAsset* asset = NvFlexExtCreateSoftFromMesh( ....... ); NvFlexExtDestroyAsset(asset); However, my code isn't set up in a friendly way to do that at the moment.

Severity of the leak: The soft has ~35,000 particles. If I run it for about 10 hours, it will use up 7 GB of memory. Of course, killing it and restarting fixes things. The leak is not precluding what I am doing; rather, it's just FYI.

Warmth, Henry C.