system.outofmemoryexception was thrown
system.outofmemoryexception was thrown occurs when there is not enough memory space for allocation of new objects. Here is a program to reproduce such kind of error using C# program.
using System;
using System.Collections.Generic;
namespace Csharp.Memory.Exception.Example
{
class Program
{
static void Main(string[] args)
{
List ul = new List();
while (true)
{
UserProfileInformation u = new UserProfileInformation();
u.FirstName = "Satalaj";
ul.Add(u);
}
}
}
public class UserProfileInformation
{
string _firstName;
public string FirstName
{
get{return _firstName;}
set{_firstName = value;}
}
}
}
How to avoid memory exception errors
To avoid memory exception kind of errors follow below steps.
1. Consider adding sufficient amount of memory [RAM] to machines.
2. If you have more than 2GB memory add 3GB switch in Boot.ini for windows XP operating system.
Upgrade to 64Bit machine, if required.
Asp.net System out of memory exception
Asp.net process model is configure to use reactive process model by default. In this case, if memory consumed by worker process w3wp exceeds 60% of available memory then it throws an memory exception.
You can configure the process model by opening IIS manager and setting application pool to use more than 60% of allowed memory.
Consider adding more physical memory. Don't load more data into Data Table objects or Dataset objects or into Session variables.
Currently rated 5.0 by 1 people
- Currently 5/5 Stars.
- 1
- 2
- 3
- 4
- 5