Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:30:14+00:00 2026-06-16T05:30:14+00:00

May be this sound stupid but, which one is the most efficient way to

  • 0

May be this sound stupid but, which one is the most efficient way to load image?

A

BitmapImage bmp = new BitmapImage();
using(FileStream fileStream = new FileStream(source_path, FileMode.Open))
{
   bmp.BeginInit();
   bmp.CacheOption = BitmapCacheOption.OnLoad;
   bmp.StreamSource = fileStream;
   bmp.EndInit();
   if (bmp.CanFreeze)
      bmp.Freeze();

   images.source = bmp;
}

B

BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bmp.UriSource = new Uri(source_path);
bmp.EndInit();
if (bmp.CanFreeze)
   bmp.Freeze();

images.Source = bmp;

I remember I read somewhere that loading from a stream completely disables the cache. If thats true, does it means loading from a stream is better in term on memory management?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:30:15+00:00Added an answer on June 16, 2026 at 5:30 am

    As far as i have understood, when you load a BitmapImage by setting its UriSource property, the image is always cached. I don’t know of any way to avoid this. At least setting BitmapCreateOptions.IgnoreImageCache only ensures that an image is not retrieved from the cache, but it does not prevent that the image is stored in the cache.

    The “Remarks” in BitmapCreateOptions says that

    When IgnoreImageCache is selected, any existing entries in the image
    cache are replaced even if they share the same Uri

    My conclusion from this is that caching is only performed when an image is loaded by an Uri. In other words, if you really need to inhibit image caching, you will have to load an image by its StreamSource property.

    However, if this is really “better in terms of memory management” is perhaps worth an experiment. You could try out both alternatives and see if you observe any significant difference in memory consumption.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may sound like a stupid question, but if one locks a resource in
This may sound stupid, but is there a way to open terminal and execute
I'm new to CodeIgniter, so this may sound a bit stupid. But here's what
This may sound stupid but... When I create big SQL commands I want to
This may sound like a stupid question but I can't seem to find an
This may sound like a stupid question but I'm a beginner not just to
This may sound like a stupid question, perhaps it is. But I'm only trying
I'm trying to studdy some performace things... this question may sound stupid, but I'll
This may sound really stupid. but I've got a strange problem with the D
This may sound like a stupid question, but can DI be used everywhere where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.