Dealing with Large JSON Strings in ASP.NET MVC Views

Large JSON Objects (approximately 1.5 MB) are received in Controller C1. They are then converted to strings and stored in a hidden label in View V1.

The JSON data in V1 is utilized by parsing it in JavaScript J1.

An occurrence of

Out of Memory Exception

has been noticed occasionally on the ASP.NET MVC page.

There is uncertainty about whether the large JSON strings in View V1 could be the cause of this issue.

  1. Could the extensive JSON strings be responsible for the OOM Exception?
  2. Is there a more efficient method to handle the substantial JSON strings in JavaScript J1?

Answer №1

Let's start with a few questions:

  • At what point do you encounter this exception?
  • Is it when you are rendering your View?
  • Could it be when the js is trying to handle a large object in the browser?
  • Or perhaps in the Controller when attempting to retrieve this object?

If you are experiencing this error on the Server side, it might be due to your string object being larger than 85000 bytes, causing it to be moved to the LOH. This means that the object will linger in memory for quite some time until the GC finally frees up space. If you frequently use your controller method, you may run into Out of Memory (OOM) issues. I recommend profiling your application under production conditions and monitoring your memory usage.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting Problem: Incompatibility with Angular 1 and Angular 2 Hybrid Application causing Display Issue with Components

In my development work, I have created a unique hybrid application that combines Angular 1 and Angular 2 functionalities. This hybrid setup was achieved by following the guidelines provided in two helpful resources: Upgrading from AngularJS and Migrating A ...

How to transform a JSON array into individual object properties using jQuery?

In my JSON data, the structure looks like this: [ { "name": "object1", "prop": "prop1", "props": [ { "prop1": "value1" }, { "prop2": &quo ...

Creating a form that can identify both letters and numbers using JavaScript

Is it possible to create an <input> field that can recognize both letters and numbers while disregarding spaces and capitalization? Here is my current progress, aiming for the feedback to display as "right" when 9 H 6 U 8 f is entered in the field, ...

Getting the specific key of the selected item from material-ui autocomplete when onSelect is triggered, rather than simply retrieving the value

I am incorporating React with Material-ui and utilizing the Autocomplete component described in detail on this page - https://material-ui.com/components/autocomplete/ using downshift. <Downshift id="downshift-options"> ...

Guide to setting up a Node, Express, Connect-Auth, and Backbone application architecture for server-side development

As someone who primarily works on the client-side, I have recently ventured into the realm of server-side JavaScript. My initial plan for my first Node.js application involves a server-side setup that primarily serves an empty shell along with a plethora o ...

When using DataContractJsonSerializer, you can deserialize an object that may either be a string or an object

Currently, I am fetching data from an API that sends me an array. The "params" object is a string in the first element and an object in the second one. Here is how my DataContract looks: [DataMember(Name = "params")] string Params; [DataMember(Name = "p ...

Adding JSON data to an array for Flot Diagram

I've been struggling with the task of organizing data into an array. The existing temp array is structured as follows: tmp[0][0] = "NY" tmp[0][1] = "52" tmp[1][0] = "FL" tmp[1][1] = "25" My goal is to transfer this data into a new array called data. ...

Develop a PHP polling system with a limit of one vote allowed per unique IP address

My website features an Ajax Poll where users can vote multiple times after refreshing the page, with results being recorded. However, I want to restrict voting to once per IP address and show the results upon page refresh. Below is the code: The HTML Pag ...

AngularJS: incorporating various functionalities within a single controller

I have a basic AngularJS controller that I am working on, and I would like it to include two separate functions: var app = angular.module('searchApp', []); app.controller('searchCtrl', function($scope, $http, $log) { //Function 1 ...

How to establish a schema-free collection in MongoDB using Mongoose

I have a mongoose schema set up like this: var mongoose = require('mongoose'); module.exports = mongoose.model('lM', { any : mongoose.Schema.Types.Mixed, },'mlr'); In my code, I am trying to save a JSON object usi ...

Tips for transferring JavaScript values to PHP through AjaxWould you like to learn how to

Let's set the scene. I'm currently facing a challenge in passing Javascript values to different PHP functions within my ajax code so that they can be properly displayed on the page. Here is the snippet of my code: $("[data-departmen ...

Retrieve the present time of an ongoing CSS3 animation

I've been trying to retrieve the current time of a running animation, but I haven't had any luck so far. I can easily grab the start time using: myelement.addEventListener('webkitAnimationStart', function (evt){ console.log(evt.elaps ...

What is the process for displaying a String Value on the iPhone 6.0 Simulator after receiving JSON data?

Received the following data from my server: 2014-06-04 13:58:40.201 myRequest[2349:11303] parsing JSON: { "is_vip" = 1; "my_balance" = "1000.21"; "my_name" = "my_foo"; "my_num" = 100; } All values are being printed correctly. However, ...

When a radio button is clicked in Angular7 and it shares the same form control name, both radio buttons are being

Visit this StackBlitz link for more information. places = ['effil tower','new discover'] new FormGroup({place: new FormControl()}); <div *ngIf="places?.length > 0" class="col-12"> <div style=" padding-top: 1e ...

Choosing a random element in React: A step-by-step guide

I'm currently working on a dynamic website that aims to load a random header component upon each refresh. Despite my various attempts, the functionality operates smoothly during the initial load but consistently throws this error on subsequent refresh ...

Please enter only numerical values using jQuery

Currently, I am facing a slight issue. My goal is to only run the code when the input characters are numbers. This is the snippet of code I have been working with: $(".jq-sales, .jq-variablecosts, .jq-fixedcosts, .jq-additional-sales, .jq-sales-units, .j ...

What could be causing the Angular form to refresh the entire page?

Two different forms are displayed on the same page: <form ng-submit="actionA()"> <input type="text"> <input type="submit" value="Submit"> </form> <form ng-submit="actionB()"> <input type="text"> <inp ...

A method to find the sum of the final n elements in an array by employing Arr.reduceRight

I have successfully calculated the sum of the last n elements in an array using a for loop. Is it possible to achieve the same result using Arr.reduceRight instead? x = [1,2,3,4,5]; y = 0 for(let i=x.length; i>x.length-3; i--) { console.log(x[i-1]); ...

Issues with the update of class properties in Node.js using Express

I am facing some challenges with a .js Object's attribute that is not updating as expected. Being new to the world of JavaScript, I hope my problem won't be too difficult to solve. To begin with, here is a snippet from my Node class: Node = fu ...

Custom sorting in JavaScript

I have a specialized sorting method that is defined as follows sortArrayBy: function(a, b, sortKey) { if (a[sortKey] < b[sortKey]) return -1; if (a[sortKey] > b[sortKey]) return 1; return 0; }, I am looking to enhance it ...