Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@RomzMcGriess

Description

@RomzMcGriess
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.