Skip to content

Memory not released upon multiple Initialize/Shutdown #2594

@Ledragon

Description

@Ledragon

Exectuing the following code in a basic Console app leads to the application consuming more and more memory:

            Runtime.Runtime.PythonDLL = @"C:\ProgramData\WideTech\Python\python38.dll";
            PythonEngine.PythonHome = @"C:\ProgramData\WideTech\Python\";
            var count = 1000;
            for (int i = 0; i < count; i++)
            {
                PythonEngine.Initialize();
                PythonEngine.Shutdown();
            }

I am on windows 11 (64bit), using PythonNet v3.0.5, combined with Python 3.8 (happens with Python 3.12 as well).

For more context, we have a WebAPI that runs python 3 code that interacts with C# code. I tried avoiding initalization and shutdown systematically, but then I encounter API crashes. While current implementation might not be perfect (especially given 2008 - that we are facing as well, but is not the topic), it works, besides the increasing memory consumption.

Am I missing anything regarding resources freeing?

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy