UE4 plugin - possible memory leak

NatNet, VRPN, TrackD, and Plugins
Post Reply
Mernion
Posts: 3
Joined: Mon Feb 27, 2017 8:23 am

UE4 plugin - possible memory leak

Post by Mernion » Mon Feb 27, 2017 8:34 am

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?

Mernion
Posts: 3
Joined: Mon Feb 27, 2017 8:23 am

Re: UE4 plugin - possible memory leak

Post by Mernion » Thu Mar 02, 2017 1:04 am

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.

Shagan.Overman
NaturalPoint Employee
NaturalPoint Employee
Posts: 19
Joined: Mon Mar 21, 2016 2:02 pm

Re: UE4 plugin - possible memory leak

Post by Shagan.Overman » Tue Mar 07, 2017 5:21 pm

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.
-------
James Shagan Overman
Customer Experience Manager
shagan.overman@optitrack.com

ZachBrockway
NaturalPoint Employee
NaturalPoint Employee
Posts: 8
Joined: Wed Oct 21, 2015 9:25 am
Location: Corvallis, OR

Re: UE4 plugin - possible memory leak

Post by ZachBrockway » Thu Mar 09, 2017 5:41 pm

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,
Zach Brockway
Senior Software Engineer | NaturalPoint

Mernion
Posts: 3
Joined: Mon Feb 27, 2017 8:23 am

Re: UE4 plugin - possible memory leak

Post by Mernion » Tue Mar 14, 2017 1:23 am

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().

steven.andrews
NaturalPoint Employee
NaturalPoint Employee
Posts: 532
Joined: Mon Jan 19, 2015 11:52 am

Re: UE4 plugin - possible memory leak

Post by steven.andrews » Tue Mar 14, 2017 2:14 pm

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

Post Reply