Page 1 of 1

UE4 plugin - possible memory leak

Posted: Mon Feb 27, 2017 8:34 am
by Mernion
Hello.

Our team encountered possible memory leak inside natnet library with ue4 plugin. Our memory starts to consume something around 3-4 MB per one rigidbody in several seconds and literally eats 100-200 MB per several seconds when we streaming more data. Even with one tracking body it can consume several GB of memory in ten minutes.
We used ue4 memory profiles and didnot found any memory leaks in ue4 objects. Can we have get sort of information how memory management of frame data is handled inside natnet?

Re: UE4 plugin - possible memory leak

Posted: Thu Mar 02, 2017 1:04 am
by Mernion
Hi again.

We traced down problem to function in NatNetClient.h:

Code: Select all

 ErrorCode GetDataDescriptionList( sDataDescriptions** ppDataDescriptions );
We made a simple standalone project in ue4 only with starter content and optitrack plugin.
Steps to reproduce:
1) Add client origin to map (loopback from motive from saved .tak file, unicast)
2) Add cube with rigidbody.
3) Run and check to see that cube is moving around and we have no leaks in memory.
3) Inside OptitrackClientOrigin.cpp in method

Code: Select all

bool AOptitrackClientOrigin::GetLatestRigidBodyState( int32 RbId, FOptitrackRigidBodyState& OutRbState )
add code

Code: Select all

 	
sDataDescriptions* pDataDefs = nullptr;
//int nBodies = Client->GetDataDescriptions(&pDataDefs);
ErrorCode result = Client->GetDataDescriptionList(&pDataDefs); 

inside first

Code: Select all

If
4) Build, run and see how it will start to eat your memory.

Can we get some feedback on this? Looks like Client->GetDataDescriptionList(&pDataDefs) causing memory leak.
I can send our test project to someone at optitrack.

Re: UE4 plugin - possible memory leak

Posted: Tue Mar 07, 2017 5:21 pm
by Shagan.Overman
Hi,

Apologies for the delayed response. A lot of the team, myself include, just got back from GDC. This information is very helpful. We are looking into a fix now. Thankyou.

Re: UE4 plugin - possible memory leak

Posted: Thu Mar 09, 2017 5:41 pm
by ZachBrockway
Thanks for the report.

I noticed that your steps to reproduce include modifying the code of the plugin, and it's not immediately obvious why. Can you help me understand whether any such problem occurs in an unmodified copy of the plugin, and what the intent of the code change is?

Best,

Re: UE4 plugin - possible memory leak

Posted: Tue Mar 14, 2017 1:23 am
by Mernion
Changes in plugin code were caused by our code architecture.
There is no memory leak in unmodified version of plugin, because function that causing it not used.

It starts to leak only after multiply calls to Client->GetDataDescriptionList().

Re: UE4 plugin - possible memory leak

Posted: Tue Mar 14, 2017 2:14 pm
by steven.andrews
Hi Mernion,

Client->GetDataDescriptionList() is not intended to be called very often. Usually it is only called a single time when the connection to Motive is first established. While it sounds like there is a memory leak there, you should be able to use NatNet reliably even without a fix. The SampleClient.cpp provides an example for how to use the Client->GetDataDescription function.

Our developers have been notified of the memory leak and will address it when they are able.
If you have some sort of special application that requires updating assets frequently, let us know and we will see what we can do.

Best,
Steven
--
Steven Andrews
OptiTrack | Senior Customer Support Engineer