unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.27k stars 142 forks source link

Bug: Java bindings throws Out of memory error #308

Closed superkelvint closed 1 year ago

superkelvint commented 1 year ago

Describe the bug

Out of memory error with Java bindings.

Steps to reproduce

Follow the Java README code:

Index index = new Index.Config().metric("cos").dimensions(2).build();
float vec[] = {10, 20};
index.add(42, vec);
int[] keys = index.search(vec, 5);

throws this error:

Exception in thread "main" java.lang.Error: Out of memory! at cloud.unum.usearch.Index.c_add(Native Method) at cloud.unum.usearch.Index.add(Index.java:107) at TestUsearch.main(TestUsearch.java:14)

Expected behavior

No error occurs.

USearch version

2.8.10

Operating System

Ubuntu 22.04

Hardware architecture

x86

Which interface are you using?

Other bindings

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

tducthang commented 1 year ago

I've encountered a similar error too

ashvardanian commented 1 year ago

Thank you, @superkelvint and @ThangTo! Looking into it and will hopefully have a solution tomorrow 🤗

ashvardanian commented 1 year ago

:tada: This issue has been resolved in version 2.8.12 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

tducthang commented 1 year ago

@ashvardanian Thank you for updating to the new version, everything is ok. But I want to ask more about how I want to get the "cosine distance" after searching, currently the default is only [keys] It's difficult without a "distance" result.

ashvardanian commented 1 year ago

@ThangTo, sure, we can change the Java interface to be more similar to other bindings. Any chance you or @superkelvint could contribute? Thank you!

tducthang commented 1 year ago

@ashvardanian That is currently beyond my ability, I am having difficulty coding C/C++(never coded C/C++ before), can you help me. Haizz Maybe we need to wait for someone to contribute