Skip to content

Memory leak when PythonEngine.Initialize/Shutdown is called in a loop #499

@RomzMcGriess

Description

@RomzMcGriess

Environment

  • Pythonnet version: 2.3.0
  • Python version: 3.6.0
  • Operating System: Win7 x64

Details

Hello all together,
i started to use pythonnet for my application. I discovered a memory leak. I reduced my code to this to identify the leak. It appears that Python.Shutdown() does not clear all references and memory. Here is a picture of my memory diagnostics. Do i miss something? Maybe someone of you has some info.

Memory diagnostics picture

Here is my c# code:

    static void Main(string[] args)
    {
        for (int i = 0; i < 10000; i++)
        {
            Console.WriteLine($"Cycle: {i}");

            Console.WriteLine($"Status: {PythonEngine.IsInitialized}");

            if (!PythonEngine.IsInitialized)
            {
                Console.WriteLine("Initialize");
                PythonEngine.Initialize();
            }

            Console.WriteLine($"Status: {PythonEngine.IsInitialized}");

            if (PythonEngine.IsInitialized)
            {
                Console.WriteLine("Shutdown");
                PythonEngine.Shutdown();
            }

            Console.WriteLine($"Status: {PythonEngine.IsInitialized}");
        }

        Console.ReadLine();
    }

Metadata

Metadata

Assignees

No one assigned

    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