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

  • Home
  • SEARCH
  • 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 8198951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:04:19+00:00 2026-06-07T06:04:19+00:00

We have scenario of image upload in ASP.NET MVC3. Controller public ActionResult Upload(IEnumerable<HttpPostedFileBase> images,

  • 0

We have scenario of image upload in ASP.NET MVC3.

  • Controller

    public ActionResult Upload(IEnumerable<HttpPostedFileBase> images, SomeViewModel model)
    {
      foreach(var i in images)
      {
        ...
    
        byte[] fileBytes = i.InputStream.GetBytesArray();
    
        byte[] image = _imageManager.Resize(fileBytes, MaxImageWidth, MaxImageHeight, true); 
    
        ...
      }
    }
    
  • ImageManager

    public byte[] Resize(byte[] content, int width, int height, bool preserveAR = true)
    {
      if (content == null)
        return null;
    
      WebImage wi = new WebImage(content);
    
      wi = wi.Resize(width, height, preserveAspectRatio);
    
      return wi.GetBytes();
    }
    

So we recieve image from client as HttpPostedFileBase. We pass byte[] fileBytes to Resize method of imageManager. Image manager is creating new WebImage instance, then Resize image and transform it to byte[] again.

When debugging this code, at the moment I pass wi.GetBytes() line, my memory usage raises drastically (for at least 500mb). I`m uploading image of 10mb. When uploading smaller size photos (~1.5mb) memory consumption is normal.

What can be the cause of this, and can this be fixed somehow?

Thank you

  • 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-07T06:04:20+00:00Added an answer on June 7, 2026 at 6:04 am

    Under the hood WebImage uses System.Drawing.Image.FromStream to take the original image stream and turn it into an array of bytes. I tried taking a 6.0MB JPG and calling that method on it and I got a stream with 6.0MB in it. If I ask for a BMP I get a 172MB byte aray

    I suspect you’re uploading a compressed image (e.g. PNG / JPG) and the call to GetBytes is causing the decompressed bytes of the image to be made available. When decompressed into it’s raw form it could be that the image is actually substantially larger. Not much that you can do to get around this short of dealing with Stream objects the whole way so you never load everything into memory at once.

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

Sidebar

Related Questions

I have this scenario well, i'll let the model explain. public class ScheduleMonthlyPerDayModel {
I have a scenario where users can upload an image, OR a video (from
For the following scenario: I have an ASP.NET FileUpload control and a Button that
Scenario : I have an ASP.NET MVC application developed in Visual Studio 2008. There
The environment is Windows 2008 R2, ASP.NET 4, IIS 7. I have a scenario
I have a scenario where users of my ASP.NET web application submit testimonials consisting
My scenario: I have one color background image JPG. I have one black text
This is a very common scenario: displaying images in a ListView which have to
I use an HttpHandler to dynamically serve images in a ASP.Net web application. I
I'm working with the following scenario: I have an image map with hotspots. When

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.