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

[Lgbm] fix LgbmNDArray replaced.close() release data problem #3174

Merged
merged 2 commits into from
May 12, 2024

Conversation

ewan0x79
Copy link
Contributor

Description

In LgbmNDArray, within the intern method, closing the replaced data leads to the release of floatData and doubleData. This action results in the premature release of floatData and doubleData.

@Override
public void intern(NDArray replaced) {
    if (floatData != null) {
        lightgbmlib.delete_floatArray(floatData);
    }
    if (doubleData != null) {
        lightgbmlib.delete_doubleArray(doubleData);
    }
    LgbmNDArray array = (LgbmNDArray) replaced;
    data = array.data;
    handle = array.handle;
    format = array.format;
    floatData = array.floatData;
    doubleData = array.doubleData;
    typeConstant = array.typeConstant;
    shape = array.shape;
    dataType = array.dataType;
    replaced.close();
}

@Override
public void close() {
    super.close();
    if (floatData != null) {
        lightgbmlib.delete_floatArray(floatData);
    }
    if (doubleData != null) {
        lightgbmlib.delete_doubleArray(doubleData);
    }
}

@ewan0x79 ewan0x79 requested review from zachgk, frankfliu and a team as code owners May 11, 2024 08:53
@frankfliu frankfliu merged commit abae500 into deepjavalibrary:master May 12, 2024
5 checks passed
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.

2 participants