Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in SWIG-generated proxy classes #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mjansche
Copy link

See commit 75fc31b for details.

@mjansche
Copy link
Author

This includes the commit from PR #58, which wasn't on a feature branch. Let me know if you want me to exclude that here. Or if you decide to merge this, I'll delete #58.

Pulled latest versions of config.guess and config.sub from their upstream
locations (as documented in those files). This is necessary for the
configure process to correctly recognize GNU/Linux on AAarch64, for example.
Add the %newobject SWIG declaration to the factory methods createLattice()
and createTagger() of the class MeCab::Model. This makes it clear that the
caller takes on ownership of the pointer returned by these factory methods.

Without this declaration, calls in e.g. Java to Model.createLattice() and
Model.createTagger() will leak memory, as the generatedd Java Lattice and
Tagger proxy classes do not know that they have ownership of the underlying
C++ pointers. As a result, instances of the proxy classes fail to delete
the underlying C++ objects, leading to native (off-JVM-heap) memory leaks
that are difficult to debug.
Update of auto-generated code only; no manual changes.

Reran "make" in directory mecab/swig, using current SWIG version 4.0.2.
@mjansche
Copy link
Author

The crucial commit which fixes the memory leak is now d8678ef after today's force-push to my feature branch.

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

Successfully merging this pull request may close these issues.

1 participant