Skip to content

Minimize stack memory for every CoreCLR app #3189

Closed

Description

@steveharter

The logic that the host has for initializing the CLR does not attempt to free stack-allocated temporary variables, causing perhaps a few hundred bytes to a few KB to remain on the stack unnecessarily. This affects every CoreCLR app whether launched from dotnet.exe or apphost (<myapp.exe>) since the stack never unwinds before running the app.

The memory could be freed by only keeping the necessary variables on the stack in each of the last frames that forward to the next late-bound location. I.e. refactor the code for example to pop up the stack frame(s) returning just the necessary state to that method (which frees any temporary stack state lower in the stack), and then calling the endpoint with just the minimum state on the stack, or perhaps use heap-allocated memory and free it before calling the next method.

Here are the three late-bound locations that can be optimized:

  1. In the host (corehost.cpp, run()); calls hostfxr
  2. In hostfxr.dll (fxmuxer.cpp); calls hostpolicy
  3. In hostpolicy.dll (hostpolicy.cpp); initializes the CLR

Setting milestone to 3.0 for now

Activity

  1. transferred this issue fromdotnet/core-setupon Jan 30, 2020
  2. added this to the Future milestone on Jan 30, 2020
  3. added
    untriaged
    on Feb 23, 2020
  4. removed
    untriaged
    on Feb 24, 2020
  5. dotnet-policy-service commented on Aug 25, 2024

    @dotnet-policy-service
    Contributor

    Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

    This process is part of our issue cleanup automation.

  6. added
    backlog-cleanup-candidate
    on Aug 25, 2024
  7. dotnet-policy-service commented on Sep 9, 2024

    @dotnet-policy-service
    Contributor

    This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  8. removed this from the Future milestone on Sep 9, 2024
  9. locked and limited conversation to collaborators on Oct 12, 2024
  10. removed
    backlog-cleanup-candidate
    on Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Hostenhancement

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions