shader and texture simple question

hi all,
my question is simple but very important i think:

for example i’m using the gouraud shader files then i load and use phong shader files, then if i want to use gouraud again, which is better? delete the shader if not used anymore it and then load the shader again when i want to use it or use a vector which occupies ram memory?

same thing for texture, consider if i turn the camera and the texture is not drawn anymore, should i delete it and then reload it from file or should i “save” it in the RAM?

thanks advance

Hmm, I’d say the principle of ‘avoid doing unnecessary work’ applies and boils down to:
If you do not need the resources occupied by shaders/textures/buffer objects/whatever for something else and there is even a remote chance you may need them again, don’t destroy them. If you need the resources for something else, destroy those objects first that are least likely to be needed again in the future. If you are certain you won’t need an object again, free its resources.
In particular compiling and linking shaders is not a cheap operation, the driver is running a rather powerful optimizing compiler for a non-trivial language. On the other hand compared to texture or vertex data they consume tiny amounts of memory, so they are unlikely to make a difference with respect to resource usage.

Me Hmm also - for some reason I think that the driver tosses resources between RAM and CPU memory to make a space in RAM for those only which are in use. Therefore if some resource is not used and RAM overfills, the driver deletes unused resources from RAM leaving their single copies in CPU memory only. If this is true, then there is nothing to worry about having redundant resources…

ok, i get the idea, thanks guys for the answer