2

Upload works fine for 62MB file. However, it throws exception if it is 100MB.

I found few questions in stackoverflow, but none is very specific about datatype.

Appreciate your help!

ASP.Net 4, IIS7, EntityFramework 4.1, Visual Studio 2010 SP1, SQL 2008

DataType is varbinary(max)

applicationHost.config

<section name="requestFiltering" overrideModeDefault="Allow" />

web.config

<httpRuntime maxRequestLength="1148576" executionTimeout="3600"/>

<security >
  <requestFiltering>
    <requestLimits maxAllowedContentLength="112400000" />
  </requestFiltering>
</security>

I use EntityDataModel. The following exception was thrown from designer.

enter image description here

enter image description here

Win
  • 61,100
  • 13
  • 102
  • 181

1 Answers1

2

Looks like your file is too big for your memory. This is probably because the bytes of the file are copied a few times during your processing, multiplying their size in the process.

What surprises you about this error?

usr
  • 168,620
  • 35
  • 240
  • 369
  • Local computer and server both still have a lot of memory. Am I missing something or EF doens't allow 100MB file? Thanks! – Win Mar 30 '12 at 23:35
  • 1
    Is your process 32 bit? In any case, nobody is deliberately throwing OOM. You **are** OOM, you just don't know why. – usr Mar 30 '12 at 23:47
  • 1
    I don't know what you do with the contents of the file in your app but as per MSDN: "This method must return a copy of the values because byte arrays are mutable without providing a reliable mechanism for tracking changes." - so EF already creates two copies of the array. If you read the contents of the file to an array to set the property you probably have one more copy. If you saved the data to the database I think EF may one more copy in the original values... – Pawel Mar 31 '12 at 03:17
  • usr & Pawel - Without your helps, I would have been digging through my codes for few days. Thank you! When I rewrote the method using StoreProcedure calling from EF, I'm able to upload 200MB file. So, inserting a large data using AddObject becomes issue in EF. Is there any working around rather than using StoreProcedure? – Win Apr 01 '12 at 20:04
  • 2
    What you really *should* do is to use the WRITE clause of the update statement (http://msdn.microsoft.com/en-us/library/ms177523.aspx) to stream data into sql server. This allows you to upload arbitrarily large files. The EF is not a good fit for this. – usr Apr 01 '12 at 20:11
  • 2
    @user - You rock! Update with WRITE works. I also attached the link so that other can use it. Thank you again for your help! http://stackoverflow.com/questions/1942609/sql-sequentially-doing-update-write-on-varbinary-column – Win Apr 02 '12 at 15:37