microsoft / microsoft/OpenAPI.NET.OData

EntityModel.ConvertToOpenApi method memory usage

Open
#389 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
240
Forks
70
Avg merge
7h 59m
Merged PRs (30d)
13

Description

When using IEdmModel.ConvertToOpenApi - some EDMX documents appear to trigger massive memory usage on some occasions it never seems to finish, I've left it for upwards of 30 minutes. I am trying to generate documentation for Microsoft Dynamics Business Central API's.

Assemblies affected

This is a C# WPF .NET7.0 app

  • Microsoft.OpenApi V1.6.4
  • Microsoft.OpenApi.OData V1.4.0
  • Microsoft.OpenApi.Readers V1.6.4

Microsoft.OpenApi.OData.EdmModelOpenApiExtensions.ConvertToOpenApi()

Steps to reproduce

the below code in conjunction with the example EDMX examples replicates the issue

var EdmData = System.IO.File.ReadAllText(ExampleEdmxFilePath);
IEdmModel model = CsdlReader.Parse(XElement.Parse(EdmData).CreateReader());
var document = EntityModel.ConvertToOpenApi();

Expected result

The OpenApiDocument is created quickly and with reasonable memory usage

Actual result

The OpenApiDocument is not created/created very slowly and uses massive amount of memory

Additional detail

From the attached zip file

  • EDMX 1 - this is a collection of ~15 custom API's - the OpenApiDocument takes around 5 minutes to be created, if I export this to a json OpenApiv3 document the resulting file is 3.5Gb and it generates ~22,000 paths, it's uses ~9Gb of memory according to Visual Studio resource profiler. If I import the OpenApiV3 Json document into Swagger it is not recognised so I suspect the 3.5Gb is just hitting some form of limit.
  • EDMX 2 - a separate set of 20 or so custom api's, appears to work correctly, the OpenApiDocument takes a few seconds to generate and uses very little memory
  • EDMX 3 - the collection of all standard Microsoft Dynamics Business Central API V2 API's, I've never got this to finish, I've left it for over 30 minutes and it's used up to 20Gb of memory.

EDMX examples.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Microsoft.OpenApi.OData.EdmModelOpenApiExtensions.ConvertToOpenApi() and reproduce the behavior using the attached EDMX examples and the C# parsing sequence in the issue. Compare the smaller working model with EDMX 1 and EDMX 3 while profiling memory and generation time. Done means the problematic EDMX documents produce an OpenApiDocument without excessive memory use or an apparent hang.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, backend-api-design, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.