faiss-node icon indicating copy to clipboard operation
faiss-node copied to clipboard

Support reset & dispose

Open asilvas opened this issue 2 years ago • 4 comments

asilvas avatar Sep 21 '23 02:09 asilvas

Thanks for your new PR, Noticed that dispose method was added. Could you please clarify the indentation? I see that it's being checked in every method, and I'm trying to understand its necessity.

Also, I noticed that the underlying implementation of the dispose method is actually calling index_.release();. If we keep this method, would it be more appropriate to rename it to release to reflect its actual functionality?

ewfian avatar Sep 21 '23 10:09 ewfian

Thanks for your new PR, Noticed that dispose method was added. Could you please clarify the indentation? I see that it's being checked in every method, and I'm trying to understand its necessity.

Also, I noticed that the underlying implementation of the dispose method is actually calling index_.release();. If we keep this method, would it be more appropriate to rename it to release to reflect its actual functionality?

Dispose is used to free all memory associated with an index. If you're OK with a segfault if calling a method on a released index, then I'm fine reverting the checks from every method.

dispose is consistent naming across ML frameworks for freeing memory. But up to you if you want to change it.

asilvas avatar Sep 21 '23 13:09 asilvas

@asilvas In the world of javascript, memory is rarely dealt with, the reset and dispose have similar uses. I want to remove the dispose method first, and merge this pr. Is this okay?

ewfian avatar Oct 02 '23 07:10 ewfian

@asilvas In the world of javascript, memory is rarely dealt with, the reset and dispose have similar uses. I want to remove the dispose method first, and merge this pr. Is this okay?

I'd prefer to keep both as there is no other way to free all memory, and have need for recreating a lot of indexes.

asilvas avatar Oct 02 '23 13:10 asilvas