Fix double ref() in static factory methods #197
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi!197
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-double-ref"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For named constructors, Java-GI generates a static factory method. This method calls the native constructor function, and then calls
InstanceCache.getForType()to wrap it in a Java proxy object with the correct class. Finally, it callsobject.ref()on the object, but this is unnecessary because the InstanceCache already added a toggle reference. This will prevent the object from being garbage-collected later, so it's a memory leak. This PR removes the doubleref().