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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:06:07+00:00 2026-05-14T23:06:07+00:00

I have webservice, with method: [WebMethod] public byte[] GetFile(string FName) { System.IO.FileStream fs1 =

  • 0

I have webservice, with method:

[WebMethod]
public byte[] GetFile(string FName)
{
    System.IO.FileStream fs1 = null;
                fs1 = System.IO.File.Open(FName, FileMode.Open, FileAccess.Read);
    byte[] b1 = new byte[fs1.Length];
    fs1.Read(b1, 0, (int)fs1.Length);
    fs1.Close();
    return b1; 
}

and it works with small file like 1mb, but when it comes to photoshop’s file (about 1,5gb) I get:

System.OutOfMemoryException

on this line:

Byte[] img = new Byte[fs.Length];

The idea is I have winforms application which get this file and saving it on local disc.

  • 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-14T23:06:08+00:00Added an answer on May 14, 2026 at 11:06 pm

    This all depends on where the exception is being thrown. Most likely what is happening is that a file that size is going into the Large Object Heap (LOH) and the memory fragmentation is causing that problem.

    http://msdn.microsoft.com/en-us/magazine/cc534993.aspx

    http://blogs.msdn.com/maoni/archive/2006/04/18/large-object-heap.aspx

    http://blogs.msdn.com/webtopics/archive/2009/05/22/Troubleshooting-System.OutOfMemoryExceptions-in-ASP.NET.aspx

    Link to a similiar SO question:
    How do I get .NET to garbage collect aggressively?

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

Sidebar

Related Questions

I have a webservice method @WebMethod public void getCapturedImages(String image) System.out.println( image + image);
i have webservice with one method which recieves xml as string: [WebMethod] public int
I have a web service that contains this method: [WebMethod] public static List<string> GetFileListOnWebServer()
Ii have a web method that looks like this: [WebMethod] public int ImportData(System.Collections.Generic.List<Record> importRecords)
If I have a web service method, e.g. [WebMethod] [XmlInclude(typeof(SportsCar)), XmlInclude(typeof(FamilyCar))] public Car[] GetCars()
I have a simple web service like this: @WebService public class MyWebService { @WebMethod
I have some ASP.NET page and webservice WebMethod() methods that I'd like to add
I have created a console application that calls a method on a webservice. I
All the generated webservice-stubs from our backend have an equals-method similar to this one:
I have a ASP.NET SOAP web service whose web method creates a PDF file,

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.