Skip to content

Confusing comment and missing rationale blocking Garbage Collection #2540

Description

@guidol-ive

EPPlus usage

Commercial use (I have a commercial license)

Environment

Windows

Epplus version

8.6.3

Spreadsheet application

Excel

Description

See https://github.com/EPPlusSoftware/EPPlus/blob/develop8/src/EPPlus/ExcelPackageSettings.cs#L41

        /// <summary>
        /// Do not call garbage collection when ExcelPackage is disposed.
        /// </summary>
        public bool DoGarbageCollectOnDispose { get; set; } = true;

Suggestion 1: The summary comment is the exact oppositie of the configured default behaviour. They should align.

But on use, the garbage collection at the end can be heavy in Dispose:

                if (Settings.DoGarbageCollectOnDispose)
                {
                    GC.Collect();
                }

Measured sometimes 500 ms. During that time, all other activity on a multi user application comes to a halt:

It performs a blocking garbage collection of all generations.

according to https://learn.microsoft.com/en-us/dotnet/api/system.gc.collect?view=net-10.0

Sample measurements on our eceltable function to parse Excel of 5 rows:

  • Fresh: with GC on: 30 ms, disabled: 3 ms
  • During load: with GC on: 500 ms, disabled 2-6 ms.

Suggestion is one of the following:

  • configure default to not block all activity
  • use different collection level
  • change default when multi user environment / server GC (which is different anyway)
  • reduce need for full generations GC

Workaround:

  1. Once established as a potential blocking of activity, change configuration in code to not do blocking GC.
  2. And/or: Use CreateExcelPackage.

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions