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

[refactor] LightGBM: Use try-with-resources on autocloseable classes that manage memory #130

Open
AlbertoEAF opened this issue Jul 11, 2022 · 0 comments

Comments

@AlbertoEAF
Copy link
Contributor

Originally posted by @gandola in #116 (comment):

LightGBMBinaryClassificationModel is a autoclosable. this means that we should make use of it.

1- LightGBMBinaryClassificationModel::close() should be responsible to release all the resources related with the instance.
2- Use Try...With...Resources (similar to python With clause) to ensure that resources are released

Example:

try(final LightGBMBinaryClassificationModel model = fit(...)){
   return getClassScores(dataset, model, maxInstancesToScore);
}
// You don't need to explisitly call the close() `Try...With...Resources` will do that for you.

We should do that for all Autoclosable resources.

@AlbertoEAF AlbertoEAF changed the title [refactor] Use try-with-resources to help manage autocloseable LightGBM classes that manage memory resources [refactor] LightGBM: Use try-with-resources on autocloseable classes that manage memory Jul 11, 2022
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

No branches or pull requests

1 participant