dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.82k stars 773 forks source link

FS0193: error : Exception of type 'System.OutOfMemoryException' was thrown during compile #10581

Open vsfeedback opened 3 years ago

vsfeedback commented 3 years ago

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version of Visual Studio] out of memory error building an F# project with 1031 modules and 15619 exported functions with at least 30000 functors within the public exported function. The code is part of a open-source project https://github.com/channell/Cephei (with upto-date commit) built using VS2019 16.7.4. devenv.exe peaks at 4gb of memory, and fsc.exe hits 2gb of memory. The issue appears to be the size of the intermediate ILX produced by the F# compiler before reducing to IL for code generation because compilation time became ever slower as more compile errors (I've generated the code from a tool). I've replicated the failure with msbuild (and have dump file), but could not compile with 64-bit msbuild because of tool references.

I believe this would be resolved by running fsc.exe with 64-bit msbuild, but I'm not convinced all the referenced files are AnyCPU


Original Comments

Feedback Bot on 9/23/2020, 08:10 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

cartermp commented 3 years ago

The number of things getting compiled into a single assembly is enormous, so I don't know what all we could do.

KevinRansom commented 3 years ago

64 bit dev 17 has been announced. Consumed memory may be less of an issue.

channell commented 2 years ago

64-bit Visual Studio 2022 may have been announced but preview 2.1 still includes a x86 fsc.exe. The issue is with memory usage during compilation, and has not been resolved

vzarytovskii commented 2 years ago

Gonna reopen this one, since it's still an issue.

@TIHan fyi, you may have been looking into this one before?

We may want to use mmf when deal with ilx.

dsyme commented 2 years ago

64-bit Visual Studio 2022 may have been announced but preview 2.1 still includes a x86 fsc.exe.

I didn't realise fsc.exe was still 32-bit.

Can we put include an fsc64.exe and use that by default?

channell commented 2 years ago

This is important for one of the global Banks that depend on F# for quantitative finance, that has also experienced this "issue". It's an issue rather than a fault because all functional languages use more (compilation) memory for type inference.
It is an issue for F# because [1] it does more type inference than other languages [2] large F# projects run to millions of lines of code (even though they are a fraction of the size of a comparable imperative libraries).