I\'m developing a BlackJack program which shows a BlackJack Table, cards, etc. The plan is that it\'ll be playing thousands of hands one after another with an automated strategy
So first off, you only have 52 cards. Just create the images up front and keep them around for the life of the application. It is a Black Jack game after all; it is safe to assume that each card will be needed at one point or another.
That said, there is an issue with creating BitmapSource
objects from streams. The byte[]
held by the stream is not being freed when the stream is disposed. See my own question here. The only reason I didn't vote to close as a duplicate is because I think you should really just create the cards once and be done with it instead of creating these images 10,000+ times.