Note that there are some explanatory texts on larger screens.

plurals
  1. POSystem.OutOfMemoryException: Exception when uploading a file
    text
    copied!<p>I'm getting this error when uploading a file that is 84MB (see error below) but when I upload a ~60MB file, it works fine. This only occurs on our 32bit 2008 VM w/ 4GB memory. On my R2 64bit VM w/8GB memory, it works fine with even 130MB file.</p> <blockquote> <p>System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.IO.BinaryReader.ReadBytes(Int32 count) at CustWeb.Controllers.DownloadsController.Create(Download dl, HttpPostedFileBase file) in c:\...\CustWeb\Controllers\DownloadsController.cs:line 72</p> </blockquote> <p>I monitored the Memory in the task manager, though, and it never goes above 74% during the entire upload process.</p> <p>This is an MVC 4 application on the 4.5 .NET framework.</p> <p>I have the max settings in my web.config in dealing with uploading files.</p> <pre><code>&lt;httpRuntime requestValidationMode="4.5" targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="84000" /&gt; </code></pre> <p>...</p> <pre><code>&lt;security&gt; &lt;requestFiltering&gt; &lt;requestLimits maxAllowedContentLength="2147482624" /&gt; &lt;/requestFiltering&gt; &lt;/security&gt; </code></pre> <p><strong>UPDATE</strong> Adding code as requested:</p> <pre><code> public ActionResult Create(Download dl, HttpPostedFileBase file) { try { using (var binaryReader = new BinaryReader(file.InputStream)) { dl.FileBytes = binaryReader.ReadBytes(file.ContentLength); } dl.FileContentType = file.ContentType; dl.FileName = file.FileName; dl.Insert(); Success("&lt;strong&gt;" + dl.Label + "&lt;/strong&gt; created and uploaded successfully."); return RedirectToAction("Index"); } catch (Exception ex) { SelectList list = new SelectList(new DownloadType().GetDownloadTypes(), "ID", "Name"); ViewBag.DownloadTypeList = list; Error(ex.ToString()); return View(dl); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload