GC problems in CapturePreviewCSharp/StillsCSharp examples

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

zwang135

  • Posts: 13
  • Joined: Fri May 04, 2018 1:30 am
  • Real Name: Zicheng Wang

GC problems in CapturePreviewCSharp/StillsCSharp examples

PostWed May 23, 2018 5:44 am

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 1762 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!
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 442
  • Joined: Mon Sep 04, 2017 4:05 am

Re: GC problems in CapturePreviewCSharp/StillsCSharp example

PostFri May 25, 2018 3:05 am

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
Offline

zwang135

  • Posts: 13
  • Joined: Fri May 04, 2018 1:30 am
  • Real Name: Zicheng Wang

Re: GC problems in CapturePreviewCSharp/StillsCSharp example

PostWed May 30, 2018 9:44 am

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
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 442
  • Joined: Mon Sep 04, 2017 4:05 am

Re: GC problems in CapturePreviewCSharp/StillsCSharp example

PostFri Jun 01, 2018 3:11 am

Hi Zicheng,

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

Regards
Cameron

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 19 guests