Let's say that I have to show some graphics on some control. But there will be three images switched based on some condition. Three bitmap is added in the resource file.
So, I retrieve them by calling ResourceManager.GetObject.
The question is that, should it be:
Doing 1) seems to produce a lot of GC Handle when viewed with CLR Profiler. Hoping to know any bad side effect of 2).
Thanks a lot.
Each call to GetObject
will read the image from the assembly and load it into a Bitmap
object.
Calling it many times will create significant overhead; you should store the images.