Skip to content

Memory leaks in MFC dialog base application when use scoped_interpreter #2062

@ruoleng

Description

@ruoleng

The example code in VC 2017 give a leak tip in debug mode.
Output windows show text like this:

Detected memory leaks!
Dumping objects ->
{266} normal block at 0x00C9B4E8, 4 bytes long.
Data: < > 00 00 00 00
Object dump complete.

I had try the code in Win32 Application, it's OK, no leak.

The version of Visual Stuido 2017 I'm using is 15.9.16.

It seem the "internals_pp" pointer did not release.
In "internals.h" file of function "inline internals **&get_internals_pp() ".

Reproducible example code

namespace py = pybind11;
py::scoped_interpreter guard{};
auto dtPassTo = py::dict();
auto global = py::dict(py::module::import("main").attr("dict"));
dtPassTo["msg"] = py::cpp_function(
[](std::string strMsg) {
::MessageBoxA(nullptr, strMsg.c_str(), "", MB_OK);
});

py::exec("msg('test')", global, dtPassTo);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions