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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:17:21+00:00 2026-05-25T14:17:21+00:00

I got a WCF service that has simple method called GetLineBusses. public MobileResponse GetLineBusses(MobileRequest

  • 0

I got a WCF service that has simple method called GetLineBusses.

public MobileResponse GetLineBusses(MobileRequest Request)
    {
        MobileResponse response = new MobileResponse();
        using (var entities = new NerdeBuOtobusEntities())
        {


            Line line = null;
            List<Point> points = new List<Point>();
            City city = entities.Cities.SingleOrDefault(t => t.ID == Request.CityID);
            try
            {
                line = entities.Lines.SingleOrDefault(t => t.ID == Request.LineID);
                //if (line != null)
                //{
                //    points = entities.Points.ToList().Where(t => t.LineID == Request.LineID && Request.WithPoints == true).ToList();
                //}
            }
            catch (System.Exception ex)
            {

            }
            FetcherManager fetcherManager = new FetcherManager(city);
            List<Bus> busses = fetcherManager.GetLineBusses(line);

            List<BusDTO> busDtos = new List<BusDTO>();

            foreach (Bus bus in busses)
            {
                BusDTO aBus = new BusDTO(bus);
                busDtos.Add(aBus);
            }
            response.Points = points.Select(t => new PointDTO(t)).ToList();
            response.Busses = busDtos;
        }

        return response;
    }

What I observed is that when I publish the method above, each query to method increases my IIS worker process ram use up to 160,000 kb. In order to find out the problem, I commented out

City city = entities.Cities.SingleOrDefault(t => t.ID == Request.CityID);

and

line = entities.Lines.SingleOrDefault(t => t.ID == Request.LineID);

Now that the ram use for method is minimized to 20,000. I think the problem is because of entity framework especially LINQ. By the way, I have tried static queries in order to decrease the memory use however It did not work at all. How can I solve this problem? I want to minimize the ram use by using LINQ…

Regards

Kemal

  • 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-25T14:17:22+00:00Added an answer on May 25, 2026 at 2:17 pm

    The below line is calling ToList() on entities.Points. This results in the entire Points table being loaded into the DataContext, and then the Where() clause is applied.

    points = entities.Points.ToList().Where(t => t.LineID == Request.LineID && Request.WithPoints == true).ToList(); 
    

    Try removing the ToList() after entities.Points. For example,

    points = entities.Points.Where(t => t.LineID == Request.LineID && Request.WithPoints == true).ToList(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a WCF service that offers a Login method. A client is required
I've got a WCF Web Service method whose prototype is: [OperationContract] Response<List<Customer>> GetCustomers(); When
I've got a method on a WCF service that returns an ObservableCollection<T> . On
Let's say you've got a WCF service that is accessible via HTTP and HTTPS,
I'm working on a WCF service that requires Membership and Profile access. I got
We've got a scheduling application running that calls a WCF service to run nightly
I've got a WCF service with lots of method and DataContracts. It is usually
We've got the following WCF Service Contracts: [ServiceContract(Namespace = http://example.com, Name = Service1)] public
I've got a central SQL server database. My solution has a WCF service responsible
I've got a WCF service that will need to receive client credentials, and maintain

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.