Skip to content

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

Description

@AlbertoEAF

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.

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