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

Memory Leak - new PyObject #170

Open
prsvic opened this issue Aug 22, 2019 · 0 comments
Open

Memory Leak - new PyObject #170

prsvic opened this issue Aug 22, 2019 · 0 comments

Comments

@prsvic
Copy link

prsvic commented Aug 22, 2019

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant