CIFilter creation static vs dynamic

This may sound dumb, but if the app is using 100 CIFilters at different times to video frames during video playback, should all CIFilters be preallocated and initialised, or it is okay to create CIFilters as and when needed? I have always created them statically before video playback begins, but I need to do if there is any difference in performance if create them dynamically as and when needed during video playback.

Replies

A CIFilter is usually just a very small wrapper around a CIKernel, which is basically a bit of (intermediate) code that can be run on the GPU. When you apply a filter (chain) Core Image will optimize, potentially concatenate and finally compile the code and send it to the GPU. The Core Image runtime will probably perform some caching of those kernels, but I'm not sure.
To summarize, CIFilters should have a very small memory footprint and you probably benefit more from caching when you re-use them instead of instantiating them on-the-fly.