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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:17:32+00:00 2026-05-22T16:17:32+00:00

I have code that passes almost 1MB of data from my controller to the

  • 0

I have code that passes almost 1MB of data from my controller to the view through a viewmodel each time a new page is called. I could optimize this slightly but I am wondering if this would be worth doing as the flow of data is all internal.

Typical of what I am doing in the controller is that I am getting all test results from an Azure datastore and then putting them in a new instance of a class. I am then passing this class and others onto a view. I guess I am not sure. Would the data be passed by reference or would actual data be moved from one place to another?

Anyone have any experience with this side of performance tuning for MVC3?

Here’s a made up example. In this example it’s nice and easy to pass the “TestData” class and contents to the view but then I just need a couple of items from this class. So I’m wondering if I should add logic in the controller and add fields in the view model for these items or just not bother and move across all the class data including the data I don’t need.

public class testIndexViewModel
{
    public string   Url { get; set; }
    public PageMeta PageMeta { get; set; }
    public TestData TestData { get; set; }
}

Thanks,

  • 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-22T16:17:32+00:00Added an answer on May 22, 2026 at 4:17 pm

    The ViewModel class that you create gets added to the ViewDataDictionary which your compiled custom View class accesses through its base System.Web.Mvc.ViewPage<ViewModelType> class. All that means is that I’m pretty sure your ViewModel – once it’s created – is always accessed by reference, and not copied around the place.

    The only performance issue you could come across (I suppose) would be consequent to creating a 1MB object in the first place; how many of these objects are you likely to be creating, and how often?

    Personally, I’d not worry about performance optimisation without first load testing and noticing that it’s actually causing a problem. If it does and your application only really needs a fraction of the data at any one time, you can build in an optimisation then.

    Finally, if you have code in your View to sift through your 1MB of data and pick out the sections you want to display, you might want to only pass the View the data it needs in order to make the code more readable, and better separate the Controller and View’s responsibilities.

    http://en.wikipedia.org/wiki/Premature_optimization#When_to_optimize

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

Sidebar

Related Questions

I have a bit of code that passes around a ton of objects and
I have code that looks like: //System.Data.IDataRecord dr try { Consolidated = Utility.NullConvert.ToBool(dr[Constants.Data.Columns.cConsolidated], false);
I have written a timer application that passes a speechTime from an IBAction and
I have some C code that parses a file and generates another file of
I have the following code in a Runnable that gets passed to a thread
I have code that references a web service, and I'd like the address of
I have code that looks like the following, which works fine for displaying the
I have code that looks like this: template<class T> class list { public: class
I have code that I want to look like this: List<Type> Os; ... foreach
I have code that uses Win API function RegSaveKeyEx to save registry entries to

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.