Skip to content

Results.File and Results.Stream consume large amount of Memory, don't stream file directly anymore #45037

@davepermen

Description

@davepermen

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

using MapGet("/", () => Results.File("bigfile.bin")) causes huge amount of memory consumption, and multiple seconds of delay till the download starts.

In .net6, download started instantly and used up no memory.

Same Issue on Results.Stream

Bug with screenshots for comparison visible here:

image
image

Expected Behavior

Results.File and Results.Stream should directly stream the file download without loading it first into ram.

Steps To Reproduce

I created a repo here, needs a big file in wwwroot/1gb.bin

https://github.com/davepermen/ResultsFileBug

to create file quickly (on windows): open cmd in wwwroot and run "fsutil file createnew 1gb.bin 1073741824" but any file works.

switch project between net6 and net7 to see the effect.

Exceptions (if any)

No response

.NET Version

7.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    old-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions