Hello friends I'm working asp.net application on windows server 2003.I have upgrade the application from .net 1.1 to .net 2.0 first I'm getting few warnings and every thing is working fine but last few days site getting crash due to the exception mention below.I'm not good at server related things so need some help.


Event Type: Error
Event Source: ASP.NET 2.0.50727.0
Event Category: None
Event ID: 1334
Date: 1/17/2012
Time: 6:03:22 PM
User: N/A
Computer: IRDA
Description:
An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/76055389/Root

Process ID: 3108

Exception: System.OutOfMemoryException

Message: Exception of type 'System.OutOfMemoryException' was thrown.

StackTrace: at System.Threading.ExecutionContext.CreateCopy() at System.Threading._TimerCallback.PerformTimerCallback(Object state)
--------------------------------------------------------------------------------------------------------------------------------------
Event Type: Error
Event Source: .NET Runtime 2.0 Error Reporting
Event Category: None
Event ID: 5000
Date: 1/17/2012
Time: 6:03:23 PM
User: N/A
Computer: IRDA
Description:
EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.3959, P3 45d6968e, P4 mscorlib, P5 , P6 492b834a, P7 11eb, P8 18, P9 system.outofmemoryexception, P10 NIL.
--------------------------------------------------------------------------------------------------------------------------------------
Event Type: Error
Event Source: VsJITDebugger
Event Category: None
Event ID: 4096
Date: 1/17/2012
Time: 6:03:28 PM
User: NT AUTHORITY\NETWORK SERVICE
Computer: IRDA
Description:
An unhandled exception ('System.OutOfMemoryException') occurred in w3wp.exe [3108]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on.


thanks in advance,
Abrar

Dani AI

Generated

Short diagnosis and where to look first — this looks less like a single bad SQL call and more like a background-timer + process-address-space problem. ’s infinite-loop idea and ’s large-result concerns are both valid causes of high memory, but the crash coming from the timer/ExecutionContext path typically means (a) the worker process is exhausting its 32‑bit virtual address space or LOH fragmentation is blocking a large contiguous allocation, or (b) a timer/ThreadPool callback is repeatedly capturing a large ExecutionContext (closures, HttpContext/CallContext data, big buffers) and holding it alive.

Concrete, ordered troubleshooting steps (do these now):

  • Start PerfMon and log Process\Private Bytes, Process\Virtual Bytes, .NET CLR Memory# Bytes in all Heaps, .NET CLR Memory\Large Object Heap size, and % Time in GC while you reproduce or wait for the failure.
  • If you see growth, capture full process dumps at several points (DebugDiag or ProcDump) and analyze with WinDbg + SOS (!dumpheap -stat, !eeheap -gc) or use DebugDiag’s memory analysis.
  • Rule of thumb: Private Bytes and CLR heap growth together → managed leak; Private Bytes rising while CLR heaps remain flat → native leak or fragmentation.

Short-term mitigations and a code pattern to fix timer captures:

  • Configure the IIS app‑pool memory recycle limits (Maximum used/virtual memory) to a conservative value so a single OOM won’t take the whole site down (remember in‑proc sessions are lost on recycle).
  • Reduce per-page memory: stream rows (IDataReader), add paging, avoid caching full tables in Session/Application.
  • If you use System.Threading.Timer or queue background work from request threads, prevent EC capture at timer creation time. Example:
    // suppress ExecutionContext flow while creating the timer so it doesn't capture request state
    using (System.Threading.ExecutionContext.SuppressFlow())
    {
      _timer = new System.Threading.Timer(TimerTickCallback, null, dueMs, periodMs);
    }

    Suppressing flow prevents the runtime from copying request-specific context into the timer; use it only when the callback does not need impersonation/call-context data.

Priority checklist to resolve permanently:

  1. Capture and analyze dumps to identify hot types or pinned large arrays.
  2. Audit all timers/background queues for closures or large state and either pass minimal state or use UnsafeQueueUserWorkItem / suppressed ExecutionContext when safe.
  3. Remove large in‑memory DataTables: page or stream.
  4. Keep a conservative app‑pool memory recycle as a safety valve while you fix leaks/fragmentation.

(References above point to Microsoft CLR/IIS and ExecutionContext sources for the behaviors and tools mentioned.)

Recommended Answers

All 5 Replies

Abrar, this error usually occures when your application is having an infinte loop. Please debug your CreateCopy() function and see if there is any false condtion to break the loop?

Thanks for reply

where should I found that method(CreateCopy()) I've no Idea I think its a predefined method.

Where abouts in your code does the crash occur? If you can narrow down what code is running when it happens that will help.

hello!
this error occurred when your memory or RAM is full,so i think in your application you retrieve data from database,so if it's the case,your data is so huge that your memory can't handle,so you must for example retrieve a little number of rows from the database.
provide us any more details for helping you better.
Regards!

Thanks alot for replying.
Yes we are retrieving huge data almost on every page but our server memory is 4gb RAM so I think its enough.But this error comes once in a while and the site gets down.I'm working on the sufyan2011 solution hope it fix the error and please help me in the easiest way to fix this problem as soon as possible.
Thanks & Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.