Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Memory Leak - new PyObject #170

Open

Description

@prsvic

Hello guys,

I noticed that when creating a PyObject in Java using method call(...) or callMethod(...), it lives forever....

In method PyLib_CallAndReturnObject, an object is first created
(pyReturnValue = PyObject_CallObject), then its reference is incremented
(Py_INCREF (pyReturnValue)), and then the reference is incremented again in the PyObject constructor in Java:

    PyObject(long pointer) {
        if (pointer == 0) {
            throw new IllegalArgumentException("pointer == 0");
        }
        PyLib.incRef(pointer);
        this.pointer = pointer;
    }

However, I found only one case, when the counter decrements - the PyObject's finalize(). Therefore, the object continues to exist with two references, and a memory leak occurs.
Is this a bug, or am I misunderstanding something? (sorry, this is my first expirience with Python C API)

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions