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 6609405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:42:51+00:00 2026-05-25T19:42:51+00:00

I have some images stored in a database as base64 strings and need to

  • 0

I have some images stored in a database as base64 strings and need to return them from an MVC controller. How can I do that without a memory leak?

Previously I was using this:

return File(Convert.FromBase64String(pictureString), "image/jpeg");

However, the w3wp process starts using up a whole heap of memory for a few photos.

Is there a proper way to do this? Currently I’ve decided just to set each image to data:image/jpg;base64,string_here and it uses a lot less memory.. but it seems to be a lot slower loading the page too.

Any help is appreciated.

  • 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-05-25T19:42:51+00:00Added an answer on May 25, 2026 at 7:42 pm

    +1 To Darin Dimitrov’s comment.

    If images / base64 encoded data are more than 85K it will be allocated on LOH (lage objects heap). GC for such allocations is more expensive due to need to wait for generation 2 collection.

    Another approach if you have to keep using base64 encoded images is to implement your own stream that reads data from the Base64 encoded value in chunks to avoid allocation of second large block of memory. If you can read string in chunck also you will be able to avoid allocation of objects on LOH and potentially just reuse realitely small buffers to read/decode.

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

Sidebar

Related Questions

I have stored some images in database, while retrieving them i want to resize
I have some images that need to change, based not only on hover, but
I have a thread that downloads some images from internet using different proxies. Sometimes
I have some pretty large PNG images stored in a database (example 1000x15000 px,
I have a SQL database that contains images stored as a byte array. I
I have some images in a mysql database stored as BLOB's. The maximum file
I have some static images in a folder on my IIS 6-based website that
I have some text/images that I only want to display in the normal state
I have some static resources (images and HTML files) that will be localized. One
I have a div with id=images. The div contains some images that are each

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.