|
FAQ
"OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown"
|
|
|
|
I got error "OutOfMemoryException: Exception of type
System.OutOfMemoryException was thrown"
SUMMARY
During the upload process, ASP.NET loads the whole file in memory before the
user can save the file to the disk. Therefore, the process may recycle because
of the memoryLimit attribute of the processModel
tag in the Machine.config file. The memoryLimit attribute
specifies the percentage of physical memory that the ASP.NET worker process can
exhaust before the process is automatically recycled. Recycling prevents memory
leaks from causing ASP.NET to crash or to stop responding.
Additionally, other factors play a role in the maximum file size that can be
uploaded. These factors include available memory, available hard disk space,
processor speed, and current network traffic. With regular traffic of files
being uploaded, Microsoft recommends that you use a maximum file size in the
range of 10 to 20 megabytes (MB). If you rarely upload files, the maximum file
size may be 100 MB.
You may notice the following error messages if you encounter file size limits
during the file upload process then using ASP.NET built-in upload class:
-
The page cannot be displayed.
-
Server Application is Unavailable.
In the event log, the error message will be similar to the following:
aspnet_wp.exe (PID:PIDNumber) was recycled because memory consumption exceeded
the SizeLimit MB (Percentage percent of available RAM).
-
Exception of type System.OutOfMemoryException was thrown.
You may also find that uploads occur very slowly. If you watch the
Aspnet_wp.exe process in Windows Task Manager, you will notice that the memory
delta changes by 64 KB every 1 to 2 seconds. Depending on the size of the file,
this delay may cause the ASP.NET worker process to recycle because of a
responseDeadlock error.
SOLUTION
PowUpload ASP.NET control handles and
stores the contents of the POST request to a file on the server hard disk
rather than loading it into memory as the built-in ASP.NET upload support does
so you willn't have problems with memory use while uploading large files.
REFERENCES
Microsoft KB Article:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;295626
|