Page 1 of 1

GC problems in CapturePreviewCSharp/StillsCSharp examples

PostPosted: Wed May 23, 2018 5:44 am
by zwang135
Hello forum!

I'm currently working with the two C# examples from the SDK mentioned in title. They are both very helpful to me especially the new released one, but I got some GC problems when running them.

When running x64, they work fine but they don't clean up garbage right away, resulting in taking too much memory when running.
0.png
0.png (66.54 KiB) Viewed 585 times


When running x86/AnyCPU they just don't clean up when the memory gets full, and stop capturing more frames at that point. Any advice on how to deal with this problem? Thanks!

Re: GC problems in CapturePreviewCSharp/StillsCSharp example

PostPosted: Fri May 25, 2018 3:05 am
by Cameron Nichols
HI Zicheng,

Can you please describe your use-case for this scenario? ie Capture or Playback, update interval, number of frames, video display mode, etc.

In the Bgra32VideoFrame class, there is large allocation of unmanaged memory. You could try calling GC.AddMemoryPressure to trigger the GC to Dispose of the class earlier.

https://msdn.microsoft.com/en-us/librar ... ssure.aspx

Please let me know if this helps.

Kind Regards
Cameron Nichols

Re: GC problems in CapturePreviewCSharp/StillsCSharp example

PostPosted: Wed May 30, 2018 9:44 am
by zwang135
Cameron Nichols wrote:HI Zicheng,

Can you please describe your use-case for this scenario? ie Capture or Playback, update interval, number of frames, video display mode, etc.

In the Bgra32VideoFrame class, there is large allocation of unmanaged memory. You could try calling GC.AddMemoryPressure to trigger the GC to Dispose of the class earlier.

https://msdn.microsoft.com/en-us/librar ... ssure.aspx

Please let me know if this helps.

Kind Regards
Cameron Nichols


Hi Cameron,

Thank you for your advice! I already solved this problem. These happened during capture, and I didn't try playback so idk if it happens in playback too.

Zicheng Wang

Re: GC problems in CapturePreviewCSharp/StillsCSharp example

PostPosted: Fri Jun 01, 2018 3:11 am
by Cameron Nichols
Hi Zicheng,

Thanks for your confirmation. We have this fix in planning for a future release.

Regards
Cameron