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

Memory leak caused by set and get methods of NDArray #2281

Closed
285220927 opened this issue Jan 3, 2023 · 0 comments · Fixed by #2300
Closed

Memory leak caused by set and get methods of NDArray #2281

285220927 opened this issue Jan 3, 2023 · 0 comments · Fixed by #2300
Assignees
Labels
bug Something isn't working

Comments

@285220927
Copy link

285220927 commented Jan 3, 2023

Description

Memory cannot be released correctly when calling get and set methods
operating system: win10
djl version: 0.20.0
jdk: 1.8

Reproduce

NDManager manager = NDManager.newBaseManager(Device.cpu());
int[] ints = new int[1000 * 1000 * 3];
Arrays.fill(ints, 1);
while (true) {
    NDManager sub = manager.newSubManager();
    NDArray array = sub.create(ints, new Shape(1000, 1000, 3));
    NDArray eq = array.eq(1);

    array.set(new NDIndex(":"), 1); // no memory leaks
    array.get(new NDIndex(":")); // no memory leaks

    array.set(eq, 1); // memory leak
    array.get(eq); // memory leak

    sub.close(); // the allocated memory cannot be fully released, and each cycle will occupy some memory that cannot be released
}

When the parameter is NDIndex, it is normal
When the parameter is NDArray, the memory usage will continue to rise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants