Gourab dhargupta
Gourab dhargupta

Reputation: 21

System.OutOfMemoryException error on js file load

@Scripts.Render() throws this error;

An exception of type 'System.OutOfMemoryException' occurred in WebGrease.dll but was not handled in user code

in my layout page when I am trying to include a 10 MB js file. Other scripts are working fine.

Upvotes: 2

Views: 1093

Answers (1)

mw509
mw509

Reputation: 2093

First of all this is not really advisable. uploading such huge files is not exactly a great solution. Do consider other methods.

In anyway, here are a few things you could try to solve your problem;

Solution 1. If you are running on 64 bit Windows and you have enough free memory, ensure that the platform target is set correctly in the project properties > build properties.

Solution 2. If you are using .NET 4.5 or greater you can add this line to the runtime section of your App.Config:

<runtime> 
   <gcallowverylargeobjects enabled="true"></gcallowverylargeobjects> 
</runtime>

Solution 3. You could increase the maxRequestLengthin your web config file.

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

Let me know if any of this works.

Reference:

[1] https://support.microsoft.com/en-us/help/2020006/how-to-troubleshoot-out-of-memory-issues-system-outofmemoryexception-i [2] https://forums.asp.net/t/1548237.aspx?ASP+NET+2+0+System+out+of+memory+exception [3] How to upload up 10gb file on ASP.NET [4] https://systemoutofmemory.com/blogs/the-programmer-blog/c-out-of-memory-exception

Upvotes: 0

Related Questions