keijiro / KlakNDI

NDI® plugin for Unity

Home Page:https://ndi.video

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory leak on OS X mono build | Unity 2021.3.10f1

marvpaul opened this issue · comments

When I attach an NDI Sender component to a GameObject, the used memory of my application blows up to over 10 GB.
I closed the previous issue as I know have created a sample project where the leak occurs as well.

  • First I came across this bug in one of my projects.
  • Then I created an empty project and imported your NDI plugin, this build works without a memory leak.
  • Finally I deleted all plugins and content from my project and now have this project: https://github.com/marvpaul/NDI-memory-leak where the leak occurs as well, empty scene with only your NDI Sender attached to the Camera, no additional plugins.

Do you have any idea what could cause this leak or how to fix? Perhaps a certain Player setting cause this leak?

@keijiro i really desperately looking for a solution.
Can you do me a favor and help with this?
I can pay hourly for your help or offer a reward of 300$ if you can find the issue for the leak on osx and help me fixing it.

EDIT: Downgraded to an older version of NDI. Looks like it solves the issue on my machine. Will rollout a bugfix and wait to customer replies.

@keijiro for some reason the downgrade worked. I downgraded to KlakNDI 4.1 and the memory leak disappeared.

We currently experience the same issue (also #165) on MacOS Silicon. An upgrade from 2021.3.13 to 2021.3.37f1 seems to solve the issue.

In 2021.3.13, there are memory allocations (4MB) which won't be deallocated (mainly on MainThread called ScratchBuffer):

measurement-small

Here the call stack of one of these allocations:

__kdebug_trace64	
-[IOGPUMetalBuffer initWithDevice:pointer:length:alignment:options:sysMemSize:gpuAddress:args:argsSize:deallocator:]	
-[AGXBuffer(Internal) initWithDevice:length:alignment:options:isSuballocDisabled:resourceInArgs:pinnedGPULocation:]	
-[AGXBuffer initWithDevice:length:alignment:options:isSuballocDisabled:pinnedGPULocation:]	
0x107656bd4	
0x10761e738	
0x10761e874	
0x10761ec80	
0x107634744	
0x106b9496c	
0x10749be78	
0x106abd830	
0x106bfb404	
0x10687ed90	
0x16fb90dc3	
0x16fb90ceb	
0x16fb90c53	
0x16fb8d9ab	
0x16fb7cc8b	
0x16fb78453	
0x16fb77ba3	
0x16fa43677	
0x16fa43943	
0x1150f914c	
0x11527f640	
mono_runtime_invoke	
0x106e00900	
0x106defd64	
0x106bf7404	
0x106aad974	
0x106c52130	
0x106c4b21c	
0x106c4b21c	
0x106c4b498	
0x1075ef848	
__NSFireTimer	
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__	
__CFRunLoopDoTimer	
__CFRunLoopDoTimers	
__CFRunLoopRun	
CFRunLoopRunSpecific	
RunCurrentEventLoopInMode	
ReceiveNextEventCommon	
_BlockUntilNextEventMatchingListInModeWithFilter	
_DPSNextEvent	
-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]	
-[NSApplication run]	
NSApplicationMain	
PlayerMain(int, char const**)	
start