class MyComProxy extends COMLateBindingObject {
...
public String getData() {
return getStringProperty("my_property");
}
}
class MyComProxy extends COMLateBindingObject {
...
public String getData() {
//return getStringProperty("my_property");
String data = createRandomDataString();
return data;
}
}--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
What you need to do is change the function signature to return a Pointer, create a String using Pointer.getString(0), and then free the pointer before returning.
On Fri, Oct 27, 2017 at 1:20 PM, sdorof <sdo...@gmail.com> wrote:HIIn my application I have a method to get a string from COM-server, like this:class MyComProxy extends COMLateBindingObject {...public String getData() {return getStringProperty("my_property");}}When the application run, the Task Manager shows endless growth in memory until the COMException "There was not enough memory to complete the operation" followed by OutOfMemory exception. This occurs about 2GB used memory as showed in the Task Manager. In the same time the java's MissionControl shows the used Heap memory less 256MB.
protected String getStringProperty(String propertyName) {VARIANT.ByReference result = new VARIANT.ByReference();
this.oleMethod(OleAuto.DISPATCH_PROPERTYGET, result,
this.getIDispatch(), propertyName);
String res = result.stringValue();
OleAuto.INSTANCE.VariantClear(result);
return res;
}
Thank you
Matthias
Thank you--Matthias
You received this message because you are subscribed to a topic in the Google Groups "Java Native Access" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jna-users/jgI3YVbKpRU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jna-users+...@googlegroups.com.