Skip to content

Question, crashes, x86, .net8 and largeaddressaware #1463

Open

Description

@podprad

I manually load coreclr 8.x.x in unmanaged x86 app compiled with largeaddressaware flag. So the process is able to use the memory above 0x80000000 (2GB).

In general, works fine, however...

Sometimes the app throws out of memory exception, for example when loading 50MB managed DLL. In such a situation VMMap shows that allocated pages occupy no more than 1.6GB. I assume I still have at least 1.0GB of free memory available, even if memory below 0x80000000 is fragmented. So why it throws?

Is there something that I am not aware of?

Best regards

Activity

  1. hundong2 commented on Jun 26, 2025

    @hundong2
    // memory status check
    GC.Collect();
    GC.WaitForPendingFinalizers();
    GC.Collect();
    
    long availableMemory = GC.GetTotalMemory(false);
    Console.WriteLine($"Available managed memory: {availableMemory / (1024 * 1024)} MB");
    
    // memory organize before load large assembly
    GC.Collect();
    GC.WaitForPendingFinalizers();
    
    //based on stream
    using (var stream = File.OpenRead("large-assembly.dll"))
    {
        var assembly = Assembly.Load(stream.ToArray());
    }
    
    //I'll recommand migration x64
    <PropertyGroup>
      <PlatformTarget>x64</PlatformTarget>
    </PropertyGroup>
    

    I think, it would be a good idea to migrate x64... ( the fundamental solution is )
    I know there're other ways to set up a memorymap.
    I hope this helps... thank you

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions