Are resource (.bmp files) that are embeded in a custom control, duplicated in memory for each use of

J

Joanne

Hi,



I have created a title bar custom control that I have added to the toolbox
and can drag and drop onto forms. The control displays one of several images
for the current operation of the form. I have created a folder of the bitmap
image files and set them as embedded resources in the custom control
project. So this custom control has embedded resource files of the various
images.



My question is this. If I drop the control onto several forms, are the
embedded resource images shared in memory or are separate instances of the
embedded resource files bmp images being duplicated in memory and wasting
space?
 
D

Darren Shaffer

Based on your description, each form that you add your custom
titlebar control to instantiates it's own copy of the imbedded images.

To prevent this, at runtime, instantiate one Image object for each
embedded bitmap and cache them, reusing them on each form's
titlebar as it needs to be displayed.

A simple way to cache them is to create a Globals class that is a
singleton to get/set your cached images.

-Darren Shaffer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top