PoseEstimation-TFLiteSwift icon indicating copy to clipboard operation
PoseEstimation-TFLiteSwift copied to clipboard

CIContext is able to generate overly

Open syjdev opened this issue 4 years ago • 1 comments

In pixelBufferFromImage(UIImageExtension),

  • https://github.com/tucan9389/PoseEstimation-TFLiteSwift/blob/e440b48bddb4459e7bf027b091a6213db4661a02/PoseEstimation-TFLiteSwift/UIImageExtension.swift

CIContext is generated whenever pixelBufferFromImage called. I recommend to use shared CIContext object(But This isn't just meaning to make single-ton). Becauase, If CIContext is generated overly then It cause memory issues(zombie object or leak). So you should use shared CIContext object as possible.

Don't worry about to use shared CIContext object. This object is thread safe.

syjdev avatar May 05 '20 15:05 syjdev

@syjdev

👍

Creating a CIContext is expensive, so create one during your initial setup and reuse it throughout your app.

ref: https://developer.apple.com/documentation/coreimage/processing_an_image_using_built-in_filters

tucan9389 avatar May 05 '20 15:05 tucan9389